forked from DonJayamanne/pythonVSCode
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Open
Labels
info-neededIssue requires more information from posterIssue requires more information from postertriage-neededNeeds assignment to the proper sub-teamNeeds assignment to the proper sub-team
Description
Type: Bug
Behavior
Pytest test discovery fails, reporting a missing import. The relevant package exists and is on the PYTHONPATH in my conda environment, but the python extension resets the PYTHONPATH to /Users/username/.vscode/extensions/ms-python.python-2025.16.0-darwin-arm64/python_files when it runs test discovery (and perhaps also tests, but I can't get that far). Running from the command line works fine.
This is a new problem -- not sure exactly when it started but I was not having it in September, so maybe with the most recent version.
Steps to reproduce:
- Create a conda environment
- Install packages in some location other than site-packages (e.g.,
$CONDA_PREFIX/share/python) - Set the
PYTHONPATHto the location of the package in the conda environement (e.g., usingconda env config vars) - Create a project in vscode
- Create a pytest test in the project that imports the package in the non-standard location
- Click the refresh tests button
Diagnostic data
Output for Python in the Output panel (View→Output, change the drop-down the upper-right of the Output panel to Python)
2025-10-20 12:54:38.840 [info] Running installed packages checker: {
id: '/Users/username/anaconda3/envs/my_conda_env/bin/python',
displayName: 'my_conda_env (3.12.11)',
detailedDisplayName: 'my_conda_env',
envType: 'Conda',
envPath: '/Users/username/anaconda3/envs/my_conda_env',
type: 'Conda',
path: '/Users/username/anaconda3/envs/my_conda_env/bin/python',
version: {
raw: '3.12.11',
major: 3,
minor: 12,
patch: 11,
build: [],
prerelease: []
},
sysVersion: '3.12.11',
architecture: 3,
sysPrefix: '/Users/username/anaconda3/envs/my_conda_env'
} /Users/username/.vscode/extensions/ms-python.python-2025.16.0-darwin-arm64/python_files/installed_check.py /Users/username/Source/my_project/pyproject.toml
2025-10-20 12:54:38.840 [info] > ~/anaconda3/envs/my_conda_env/bin/python ~/.vscode/extensions/ms-python.python-2025.16.0-darwin-arm64/python_files/installed_check.py ./pyproject.toml
2025-10-20 12:56:03.065 [info] Discover tests for workspace name: my_project - uri: /Users/username/Source/my_project
2025-10-20 12:56:03.073 [info] arg: --rootdir already exists in args, not adding.
2025-10-20 12:56:03.073 [info] Environment variables set for pytest discovery: PYTHONPATH=/Users/username/.vscode/extensions/ms-python.python-2025.16.0-darwin-arm64/python_files, TEST_RUN_PIPE=/var/folders/7b/j6zzgg8j1v3d83xn_msb1xnw0000gn/T/python-test-discovery-59c4eedeb9119bd3c322
2025-10-20 12:56:03.253 [error] ImportError while loading conftest '/Users/username/Source/my_project/tests/conftest.py'.
2025-10-20 12:56:03.277 [error] tests/conftest.py:36: in <module>
from qgis.core import (
E ModuleNotFoundError: No module named 'qgis'
2025-10-20 12:56:03.297 [error] Subprocess exited unsuccessfully with exit code 4 and signal null on workspace /Users/username/Source/project_name
2025-10-20 12:56:03.297 [error] pytest test discovery error for workspace: /Users/username/Source/project_name
The python test process was terminated before it could exit on its own, the process errored with: Code: 4, Signal: null for workspace /Users/username/Source/project_name
Extension version: 2025.16.0
VS Code version: Code 1.105.1 (7d842fb85a0275a4a8e4d7e040d2625abbf7f084, 2025-10-14T22:33:36.618Z)
OS version: Darwin arm64 24.6.0
Modes:
- Python version (& distribution if applicable, e.g. Anaconda): 3.10.18
- Type of virtual environment used (e.g. conda, venv, virtualenv, etc.): Conda
- Value of the
python.languageServersetting: Default
User Settings
condaPath: "/Users/username/anaconda3/bin/conda"
languageServer: "Pylance"
testing
• pytestArgs: ""
• pytestEnabled: true
experiments
• optInto: ["pythonTestAdapter"]
Installed Extensions
| Extension Name | Extension Id | Version |
|---|---|---|
| cmake-tools | ms- | 1.21.36 |
| copilot | Git | 1.372.0 |
| copilot-chat | Git | 0.32.3 |
| cpptools | ms- | 1.28.3 |
| cpptools-extension-pack | ms- | 1.3.1 |
| cpptools-themes | ms- | 2.0.0 |
| datawrangler | ms- | 1.22.0 |
| debugpy | ms- | 2025.14.1 |
| even-better-toml | tam | 0.21.2 |
| hexeditor | ms- | 1.11.1 |
| intellicode-api-usage-examples | Vis | 0.2.9 |
| js-debug | ms- | 1.105.0 |
| js-debug-companion | ms- | 1.1.3 |
| js-debug-nightly | ms- | 2025.10.117 |
| jupyter | ms- | 2025.9.1 |
| jupyter-keymap | ms- | 1.1.2 |
| jupyter-renderers | ms- | 1.3.0 |
| makefile-tools | ms- | 0.12.17 |
| prettier-vscode | esb | 11.0.0 |
| python | ms- | 2025.16.0 |
| remote-containers | ms- | 0.427.0 |
| ruff | cha | 2025.28.0 |
| vscode-containers | ms- | 2.2.0 |
| vscode-js-profile-table | ms- | 1.0.10 |
| vscode-jupyter-cell-tags | ms- | 0.1.9 |
| vscode-jupyter-slideshow | ms- | 0.1.6 |
| vscode-pylance | ms- | 2025.8.3 |
| vscode-python-envs | ms- | 1.10.0 |
| vscode-typescript-next | ms- | 6.0.20251019 |
| vscodeintellicode | Vis | 1.3.2 |
System Info
| Item | Value |
|---|---|
| CPUs | Apple M1 Max (10 x 2400) |
| GPU Status | 2d_canvas: enabled direct_rendering_display_compositor: disabled_off_ok gpu_compositing: enabled multiple_raster_threads: enabled_on opengl: enabled_on rasterization: enabled raw_draw: disabled_off_ok skia_graphite: enabled_on trees_in_viz: disabled_off video_decode: enabled video_encode: enabled webgl: enabled webgl2: enabled webgpu: enabled webnn: disabled_off |
| Load (avg) | 4, 4, 4 |
| Memory (System) | 64.00GB (0.35GB free) |
| Process Argv | --crash-reporter-id 7daef490-db9b-4617-abaa-559a02220920 |
| Screen Reader | no |
| VM | 0% |
A/B Experiments
vsliv368:30146709
pythonvspyt551:31249599
binariesv615:30325510
nes-control-qres:31402648
nativeloc1:31344060
dwcopilot:31170013
dwoutputs:31242946
copilot_t_ci:31333650
e5gg6876:31282496
pythonrdcb7:31342333
6518g693:31334701
aj953862:31281341
4f60g487:31327383
nes-set-on:31340697
6abeh943:31336334
envsactivate1:31353494
gendocstringt:31395207
gaj49834:31404438
cloudbuttont:31379625
todos-1:31390405
qwen_all_req:31402696
treatment_gpt5applypatchexclusively:31398171
3efgi100_wstrepl:31403338
46f5c265:31402810
trigger-command-fix:31379601
cmp-cht-code-treat-node-fetcher:31399471
auto_model_enabled:31385282
use-responses-api:31390855
applesignin:31399435
defaultusage:31403421
auto_g2946222:31402681
nes-subseq-delay-200:31400950
je187915:31401254
Metadata
Metadata
Assignees
Labels
info-neededIssue requires more information from posterIssue requires more information from postertriage-neededNeeds assignment to the proper sub-teamNeeds assignment to the proper sub-team