2024-08-07 12:48:33.346 [info] Discover tests for workspace name: *** - uri: /home/***
2024-08-07 12:48:33.346 [info] Running discovery for pytest using the new test adapter.
2024-08-07 12:48:33.346 [info] All environment variables set for pytest discovery: {*** "PYTHONPATH":"/home/kamil/.vscode/extensions/ms-python.python-2024.12.1-linux-x64/python_files:/usr/lib/python3/dist-packages", *** , "PWD":"/home/kamil",*** ,"SHELL":"/bin/bash", *** "VSCODE_AMD_ENTRYPOINT":"vs/workbench/api/node/extensionHostProcess","VSCODE_CLI":"1","VSCODE_CODE_CACHE_PATH":"/home/kamil/.config/Code/CachedData/b1c0a14de1414fcdaa400695b4db1c0799bc3124","VSCODE_CRASH_REPORTER_PROCESS_TYPE":"extensionHost","VSCODE_CWD":"/home/kamil","VSCODE_HANDLES_UNCAUGHT_ERRORS":"true","VSCODE_IPC_HOOK":"/run/user/1000/vscode-a892cd8d-1.92-main.sock","VSCODE_NLS_CONFIG":"{\"userLocale\":\"pl\",\"osLocale\":\"pl-pl\",\"resolvedLanguage\":\"en\",\"defaultMessagesFile\":\"/usr/share/code/resources/app/out/nls.messages.json\",\"locale\":\"en\",\"availableLanguages\":{}}","VSCODE_PID":"31610", *** "ELECTRON_RUN_AS_NODE":"1","APPLICATION_INSIGHTS_NO_DIAGNOSTIC_CHANNEL":"1","PATH":"/home/kamil/.poetry/bin:/home/kamil/bin:/home/kamil/.local/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin","TEST_RUN_PIPE":"/run/user/1000/python-test-discovery-23875f4f44d677193539.sock"}
2024-08-07 12:48:33.347 [warning] could not find a pixi interpreter for the interpreter at /home/kamil/.pyenv/versions/3.10.8/envs/***
2024-08-07 12:48:33.357 [info] > ~/.pyenv/versions/3.10.8/envs/***/bin/python -m pytest -p vscode_pytest --collect-only .
2024-08-07 12:48:33.357 [info] cwd: .
2024-08-07 12:48:33.562 [error] Traceback (most recent call last):
File "/home/kamil/.pyenv/versions/3.10.8/lib/python3.10/runpy.py", line 187, in _run_module_as_main
mod_name, mod_spec, code = _get_module_details(mod_name, _Error)
File "/home/kamil/.pyenv/versions/3.10.8/lib/python3.10/runpy.py", line 146, in _get_module_details
return _get_module_details(pkg_main_name, error)
File "/home/kamil/.pyenv/versions/3.10.8/lib/python3.10/runpy.py", line 110, in _get_module_details
__import__(pkg_name)
File "/home/kamil/.pyenv/versions/3.10.8/envs/lab-analysing-pkgs/lib/python3.10/site-packages/pytest/__init__.py", line 9, in <module>
from _pytest.assertion import register_assert_rewrite
File "/home/kamil/.pyenv/versions/3.10.8/envs/lab-analysing-pkgs/lib/python3.10/site-packages/_pytest/assertion/__init__.py", line 11, in <module>
from _pytest.assertion import rewrite
File "/home/kamil/.pyenv/versions/3.10.8/envs/lab-analysing-pkgs/lib/python3.10/site-packages/_pytest/assertion/rewrite.py", line 32, in <module>
from _pytest.assertion import util
File "/home/kamil/.pyenv/versions/3.10.8/envs/lab-analysing-pkgs/lib/python3.10/site-packages/_pytest/assertion/util.py", line 24, in <module>
from _pytest.config import Config
File "/home/kamil/.pyenv/versions/3.10.8/envs/lab-analysing-pkgs/lib/python3.10/site-packages/_pytest/config/__init__.py", line 40, in <module>
from pluggy import HookimplOpts
ImportError: cannot import name 'HookimplOpts' from 'pluggy' (/usr/lib/python3/dist-packages/pluggy/__init__.py)
2024-08-07 12:48:33.588 [error] Subprocess exited unsuccessfully with exit code 1 and signal null on workspace /home/kamil/***.
2024-08-07 12:48:33.589 [error] Subprocess exited unsuccessfully with exit code 1 and signal null on workspace /home/kamil/***. Creating and sending error discovery payload
2024-08-07 12:48:33.589 [error] pytest test discovery error for workspace: /home/kamil/***
The python test process was terminated before it could exit on its own, the process errored with: Code: 1, Signal: null for workspace /home/kamil/***
Type: Bug
Behaviour
Since a few weeks / months, I'm constantly falling into issues that VSCode is setting global python path instead of or before the current virtual env when invoking different extension features (tests from test explorer, Jupyter notebooks, even terminal and other Python-dependant extensions). This path was not configured anywhere, even the default interpreter has been changed. The problem existed on two independent machines, without any config sync between them. As a common thing I'd note that both VSCode instances were configured long before VSCode-Python switched to use a storage instead of config file for the Python Interpreter path.
I have managed to resolve most of the issues by removing the
~/.config/Code/Cachedirectory (maybe also some others), but now it came again, when calling pytest from the Python test explorer.Basically, pytest works well when called from terminal, but fails when trying to discover any test. Please see the logs from "Output" for Python - the PYTHONPATH is set to contain the global path, and the invoked pytest does try to use
pluggyfrom there instad of the one from venv.My suspicion is: the global path was at some point saved somewhere by the VSCode-Python extension. As the config files are no longer used for that, how could I looked up what are settings saved by the extension and remove the bad one?
This problem is extreamly irritating, couter-productive and comes back like a bumerang :(
Steps to reproduce:
Extreamly hard to say, I suspect you should have VSCode & the extension installed before the transition, and then do anything that would expect to use the local venv instead of global interpreter.
Diagnostic data
Output for
Pythonin theOutputpanel (View→Output, change the drop-down the upper-right of theOutputpanel toPython)Extension version: 2024.12.2
VS Code version: Code 1.92.0 (b1c0a14de1414fcdaa400695b4db1c0799bc3124, 2024-07-31T23:26:45.634Z)
OS version: Linux x64 6.5.0-45-generic
Modes:
python.languageServersetting: PylanceUser Settings
Installed Extensions
A/B Experiments