Python conda run incorrect environment path
See original GitHub issueBehaviour
I get the following error when running pytest test discovery. It looked like the environment path is getting duplicated: envs/kevlar/envs/kevlar
. I’m on the latest conda 4.11 and fully updated to the latest VSCode version. I’ve seen https://github.com/microsoft/vscode-python/issues/18486 and this seems related but the updates and solutions there have done nothing for me. I’ve also recreated the environment to see if a brand new environment would avoid this error.
conda run -n kevlar --no-capture-output --live-stream python ~/.vscode/extensions/ms-python.python-2022.0.1814523869/pythonFiles/get_output_via_markers.py ~/.vscode/extensions/ms-python.python-2022.0.1814523869/pythonFiles/testing_tools/run_adapter.py discover pytest -- --rootdir ./inla_explore -s --cache-clear
cwd: ./inla_explore
[ERROR 2022-1-9 14:32:9.956]: Error discovering pytest tests:
r [Error]:
EnvironmentLocationNotFound: Not a conda environment: /Users/tbent/.mambaforge/envs/kevlar/envs/kevlar
at ChildProcess.<anonymous> (/Users/tbent/.vscode/extensions/ms-python.python-2022.0.1814523869/out/client/extension.js:32:39235)
at Object.onceWrapper (events.js:422:26)
at ChildProcess.emit (events.js:315:20)
at maybeClose (internal/child_process.js:1048:16)
at Process.ChildProcess._handle.onexit (internal/child_process.js:288:5)
Expected vs. Actual
XXX
Steps to reproduce:
- Open the “Testing” panel.
Diagnostic data
- Python version (& distribution if applicable, e.g. Anaconda): 3.10.2
- Type of virtual environment used (e.g. conda, venv, virtualenv, etc.): Conda
- Value of the
python.languageServer
setting: Default
User Settings
defaultLS: {"defaultLSType":"Pylance"}
downloadLanguageServer: true
envFile: "<placeholder>"
venvPath: "<placeholder>"
venvFolders: "<placeholder>"
condaPath: "<placeholder>"
pipenvPath: "<placeholder>"
poetryPath: "<placeholder>"
languageServer: "Pylance"
linting
• enabled: true
• cwd: "<placeholder>"
• Flake8Args: "<placeholder>"
• flake8Enabled: false
• flake8Path: "<placeholder>"
• lintOnSave: true
• banditArgs: "<placeholder>"
• banditEnabled: false
• banditPath: "<placeholder>"
• mypyArgs: "<placeholder>"
• mypyEnabled: false
• mypyPath: "<placeholder>"
• pycodestyleArgs: "<placeholder>"
• pycodestyleEnabled: false
• pycodestylePath: "<placeholder>"
• prospectorArgs: "<placeholder>"
• prospectorEnabled: false
• prospectorPath: "<placeholder>"
• pydocstyleArgs: "<placeholder>"
• pydocstyleEnabled: false
• pydocstylePath: "<placeholder>"
• pylamaArgs: "<placeholder>"
• pylamaEnabled: false
• pylamaPath: "<placeholder>"
• pylintArgs: "<placeholder>"
• pylintPath: "<placeholder>"
sortImports
• args: "<placeholder>"
• path: "<placeholder>"
formatting
• autopep8Args: "<placeholder>"
• autopep8Path: "<placeholder>"
• provider: "black"
• blackArgs: "<placeholder>"
• blackPath: "<placeholder>"
• yapfArgs: "<placeholder>"
• yapfPath: "<placeholder>"
testing
• cwd: "<placeholder>"
• debugPort: 3000
• nosetestArgs: "<placeholder>"
• nosetestsEnabled: undefined
• nosetestPath: "<placeholder>"
• promptToConfigure: true
• pytestArgs: "<placeholder>"
• pytestEnabled: true
• pytestPath: "<placeholder>"
• unittestArgs: "<placeholder>"
• unittestEnabled: false
• autoTestDiscoverOnSaveEnabled: true
terminal
• activateEnvironment: true
• executeInFileDir: "<placeholder>"
• launchArgs: "<placeholder>"
experiments
• enabled: true
• optInto: []
• optOutFrom: []
insidersChannel: "off"
tensorBoard
• logDirectory: "<placeholder>"
Issue Analytics
- State:
- Created 2 years ago
- Reactions:11
- Comments:20 (7 by maintainers)
Top Results From Across the Web
Terminal PATH variables in wrong order for Conda env
All conda-installed software is not picked up if there is a version of it in /usr/local/bin. Other terminal programs do not have this...
Read more >python - PATH not updated correctly from conda activate in ...
I am using VSCodes terminal pane. I activate a conda environment. For some reason, the python command is still set to /usr/bin/python ,...
Read more >Troubleshooting
Solution . Force reinstall conda. A useful way to work off the development version of conda is to run python setup.py ...
Read more >CondaEnvironment@0 - Conda environment v0 task
Create and activate a Conda environment. ... Default: false. ... You can run scripts as subsequent build tasks that run Python, Conda, ...
Read more >Using Python environments in VS Code
By default, any Python interpreter installed runs in its own global environment. They aren't specific to a particular project. For example, if you...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
This might not be directly related, but I am able to trigger the same error as @tbenthompson in the pytest test discovery if both the following conditions are met:
Steps to reproduce:
conda create -n vscode-conda-repro python=3.9 pytest
vscode-conda-repro
environment activatedvscode-conda-repro
interpreterconda install -n vscode-conda-repro conda
and restart vscodeconda uninstall -n vscode-conda-repro conda
and restart vscodeSome notes:
vscode-conda-repro
and launch vscode from the command line (code .
) the error goes awaypython.condaPath
to the correct conda path the error goes awayv2021.12.1559732655
the error goes awayvscode-conda-repro
environmentPerhaps this is a known issue? It seems to be mentioned here: https://devblogs.microsoft.com/python/python-in-visual-studio-code-february-2022-release/#improvements-when-using-anaconda
Edit: I am running ubuntu 20.04 on WSL2 if that matters for “special characters in file paths” as mentioned in the blog.
@cswartzvi @tbenthompson Thanks for the investigation and patience. We will discuss this internally and update on this.