vscode-python: Pytest fails to use the correct conda environment path for testing
Issue Type: Bug
Pytest discover tests
I get error: EnvironmentLocationNotFound: Not a conda environment: C:\Conda\envs\swp10\envs\swp10 because the true path is just; C:\Conda\envs\swp10\
Experiment 'pythonaa' is active
Experiment 'pythonTensorboardExperiment' is active
Experiment 'PythonPyTorchProfiler' is active
Experiment 'pythonDeprecatePythonPath' is active
Experiment 'pythonInterpreterInfoPinned' is active
> conda info --json
> C:\Conda\envs\swp10\python.exe ~\.vscode\extensions\ms-python.python-2022.5.11221002\pythonFiles\get_output_via_markers.py ~\.vscode\extensions\ms-python.python-2022.5.11221002\pythonFiles\interpreterInfo.py
> C:\Conda\python.exe ~\.vscode\extensions\ms-python.python-2022.5.11221002\pythonFiles\get_output_via_markers.py ~\.vscode\extensions\ms-python.python-2022.5.11221002\pythonFiles\interpreterInfo.py
Python interpreter path: C:\Conda\envs\swp10\python.exe
> conda run -n swp10 --no-capture-output python ~\.vscode\extensions\ms-python.python-2022.5.11221002\pythonFiles\get_output_via_markers.py ~/.vscode/extensions/ms-python.python-2022.5.11221002/pythonFiles/printEnvVariables.py
> C:\Conda\envs\flights\python.exe ~\.vscode\extensions\ms-python.python-2022.5.11221002\pythonFiles\get_output_via_markers.py ~\.vscode\extensions\ms-python.python-2022.5.11221002\pythonFiles\interpreterInfo.py
> C:\Conda\envs\handson\python.exe ~\.vscode\extensions\ms-python.python-2022.5.11221002\pythonFiles\get_output_via_markers.py ~\.vscode\extensions\ms-python.python-2022.5.11221002\pythonFiles\interpreterInfo.py
> C:\Conda\envs\refining\python.exe ~\.vscode\extensions\ms-python.python-2022.5.11221002\pythonFiles\get_output_via_markers.py ~\.vscode\extensions\ms-python.python-2022.5.11221002\pythonFiles\interpreterInfo.py
Starting Pylance language server.
> conda run -n swp10 --no-capture-output python ~\.vscode\extensions\ms-python.python-2022.5.11221002\pythonFiles\get_output_via_markers.py ~/.vscode/extensions/ms-python.python-2022.5.11221002/pythonFiles/printEnvVariables.py
> conda run -n swp10 --no-capture-output python ~\.vscode\extensions\ms-python.python-2022.5.11221002\pythonFiles\get_output_via_markers.py ~\.vscode\extensions\ms-python.python-2022.5.11221002\pythonFiles\testing_tools\run_adapter.py discover pytest -- --rootdir . -s --cache-clear tests
cwd: .
[ERROR 2022-4-5 14:48:49.500]: Error discovering pytest tests:
[n [Error]:
EnvironmentLocationNotFound: Not a conda environment: C:\Conda\envs\swp10\envs\swp10
at ChildProcess.<anonymous> (c:\Users\Varo-local_User\.vscode\extensions\ms-python.python-2022.5.11221002\out\client\extension.js:2:228554)
at Object.onceWrapper (node:events:510:26)
at ChildProcess.emit (node:events:390:28)
at maybeClose (node:internal/child_process:1064:16)
at Process.ChildProcess._handle.onexit (node:internal/child_process:301:5)]
Steps to reproduce:
- Download this repo
- Open the test tab on VSCode
Diagnostic data
- Python version (& distribution if applicable, e.g. Anaconda): 3.10.4
- Type of virtual environment used (e.g. conda, venv, virtualenv, etc.): Conda
- Value of the
python.languageServer
setting: Pylance
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
• pylamaEnabled: false
formatting
• provider: “yapf”
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
experiments • enabled: true • optInto: [] • optOutFrom: []
</p>
</details>
Extension version: 2022.5.11221002
VS Code version: Code 1.66.2 (dfd34e8260c270da74b5c2d86d61aee4b6d56977, 2022-04-11T07:46:01.075Z)
OS version: Windows_NT x64 10.0.17763
Restricted Mode: No
<details>
<summary>System Info</summary>
|Item|Value|
|---|---|
|CPUs|Intel(R) Xeon(R) CPU E5-2697A v4 @ 2.60GHz (8 x 2600)|
|GPU Status|2d_canvas: unavailable_software<br>canvas_oop_rasterization: disabled_off<br>direct_rendering_display_compositor: disabled_off_ok<br>gpu_compositing: disabled_software<br>multiple_raster_threads: enabled_on<br>oop_rasterization: disabled_off<br>opengl: disabled_off<br>rasterization: disabled_software<br>raw_draw: disabled_off_ok<br>skia_renderer: enabled_on<br>video_decode: disabled_software<br>video_encode: disabled_software<br>vulkan: disabled_off<br>webgl: unavailable_software<br>webgl2: unavailable_software|
|Load (avg)|undefined|
|Memory (System)|64.00GB (48.15GB free)|
|Process Argv|D:\\DV\\VAROModule --crash-reporter-id 4258b87b-5f84-49f0-94bb-91ba84a55f17|
|Screen Reader|no|
|VM|100%|
</details><details>
<summary>A/B Experiments</summary>
vsliv368cf:30146710 vsreu685:30147344 python383:30185418 vspor879:30202332 vspor708:30202333 vspor363:30204092 pythonvspyl392:30443607 pythontb:30283811 pythonptprofiler:30281270 vshan820:30294714 vstes263:30335439 pythondataviewer:30285071 vscod805cf:30301675 pythonvspyt200:30340761 binariesv615:30325510 bridge0708:30335490 bridge0723:30353136 vsaa593cf:30376535 vsc1dst:30438360 pythonvs932:30410667 wslgetstarted:30449410 pythonvsnew555:30457759 vscscmwlcmt:30465135 cppdebug:30475216
</details>
<!-- generated by issue reporter -->
About this issue
- Original URL
- State: closed
- Created 2 years ago
- Comments: 41
I have this same problem, but in wsl. The conda environment name is dev162 located at “/home/aravia1/miniconda3/envs/dev162/” but it is looking for the environment at “/home/aravia1/miniconda3/envs/dev162/envs/dev162” and fails.
As weird as it sounds, i just tried creating a symlink at the path “/home/aravia1/miniconda3/envs/dev162/envs/dev162” and the tests gets discovered 🤷.
Symlink:
Successful test discovery:
Created a bug on conda: https://github.com/conda/conda/issues/12082, feel free to upvote that to raise priority. Closing in favor of conda.
Hey @karrtikr , got some time to check this today. Can confirm having conda in the environment was causing the test discovery to fail. The environment which I was using had
conda=4.12.0=py37h89c1867_0
and after removing it the test discovery succeeds.I tried install the latest
conda-4.14.0-py37h06a4308_0
and latest canaryconda-4.14.0+39_gde3db7f75-py37_0
, but the test discovery fails. So the solution for the time being is to remove conda from the environment.Hello! Unfortunately, I’m having the same issue in a few workspaces. It is occurring in macOS as well as ubuntu 20.04 with code-insiders and python extension v2022.12.1. Also happens when using the remote-SSH extension, but it’s not exclusive to that scenario. Can be tested with this repository.
Python extension output:
Additional environment Info:
Note that directly running the command
conda run -n ddm --no-capture-output python ~/.vscode-server-insiders/extensions/ms-python.python-2022.12.1/pythonFiles/get_output_via_markers.py ~/.vscode-server-insiders/extensions/ms-python.python-2022.12.1/pythonFiles/testing_tools/run_adapter.py discover pytest -- --rootdir . -s --cache-clear tests
in my active terminal works fine, and that terminal has already activated my virtual environment. Is there a step where it’s appending the virtual environment name and parent directory to the activatedpytest
test?Thanks in advance for help!