Repository navigation
Pytest fails to use the correct conda environment path for testing #19069
Description
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.languageServersetting: Pylance
languageServer: "Pylance"
linting
• enabled: true
• cwd: ""
• Flake8Args: ""
• flake8Enabled: false
• flake8Path: ""
• lintOnSave: true
• banditArgs: ""
• banditEnabled: false
• banditPath: ""
• mypyArgs: ""
• mypyEnabled: false
• mypyPath: ""
• pycodestyleArgs: ""
• pycodestyleEnabled: false
• pycodestylePath: ""
• prospectorArgs: ""
• prospectorEnabled: false
• prospectorPath: ""
• pydocstyleArgs: ""
• pydocstyleEnabled: false
• pylamaEnabled: false
formatting
• provider: "yapf"
testing
• cwd: ""
• debugPort: 3000
• nosetestArgs: ""
• nosetestsEnabled: undefined
• nosetestPath: ""
• promptToConfigure: true
• pytestArgs: ""
• pytestEnabled: true
• pytestPath: ""
• unittestArgs: ""
• 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 -->
Activity
1vecera commentedon May 5, 2022
Sample repo under https://github.com/1vecera/errorPytest
karrtikr commentedon May 5, 2022
Thanks for the detailed logs, meanwhile I reproduce it can you try running the command which failed in terminal and see what happens:
Make sure to expand the
~to your user directory.Please check results in both VSCode terminal and an external terminal.
1vecera commentedon May 10, 2022
Powershell, my default shell, fails both within VSCode and externally.
Simple comand line without activation runs:
Opening command in VSCode runs a conda activate script and pytest seems to pick up the wrong environment (pre-3.9 so it results in a import errors)
karrtikr commentedon May 24, 2022
Thank you for the details. It seems you likely launched VSCode from an activated terminal?
There is an issue with
conda runwhen running it from a terminal that already has an activated environment (conda/conda#11305, conda/conda#11174), so this seems to be a dup of that.37 remaining items
akzaidi commentedon Sep 28, 2022
Unfortunately, the issue persists for me in my conda environments, even after removing conda as suggested by #18493. I suppose I should wait to see if #17242 resolves my issue?
karrtikr commentedon Sep 28, 2022
Ali Zaidi (@akzaidi) Now that we can reproduce it, I'll open an issue on conda. And I'm pretty sure fixing that will also fix your issue.
Btw, can you demonstrate to me that conda is not installed in your environment?
karrtikr commentedon Sep 28, 2022
Ajith Aravind (@aaravind100) In order to open an issue on conda, can you help me with the following deets:
conda infoconda config --show-sourcesconda list --show-channel-urlsThey're needed to file a bug report on conda :)
akzaidi commentedon Sep 28, 2022
karrtikr commentedon Sep 28, 2022
aaravind100 commentedon Sep 29, 2022
Just updated to
22.9.0, the issue still persists. Here's the info below.aaravind100 commentedon Sep 29, 2022
Also found this weird path resolution problem :D
when environment is active:
when no environment is active:
karrtikr commentedon Nov 9, 2022
Created a bug on conda: conda/conda#12082, feel free to upvote that to raise priority. Closing in favor of conda.