Skip to content

pytest discovery fails with ModuleNotFound #24127

@kjohnsen

Description

@kjohnsen

Type: Bug

Behaviour

pytest discovery fails with a ModuleNotFoundError, when the module is clearly installed in my environment

Steps to reproduce:

  1. Import non-standard package (but one that is installed in the environment) in tests/conftest.py
  2. Click on refresh tests

Diagnostic data

Output for Python in the Output panel (ViewOutput, change the drop-down the upper-right of the Output panel to Python)

2024-09-18 14:18:17.711 [info] > python -m pytest -p vscode_pytest --collect-only "--rootdir=~/Dropbox (GaTech)/projects/cleo"
2024-09-18 14:18:17.711 [info] cwd: ~/Dropbox (GaTech)/projects/cleo
2024-09-18 14:18:18.046 [info] Plugin info[vscode-pytest]: Checking if rootdir is a child of a symlink.
Checking for symlink parent starting at current path:  /home/kyle/Dropbox (GaTech)/projects/cleo
Symlink found at: /home/kyle/Dropbox (GaTech)
Plugin info[vscode-pytest]: rootdir argument, /home/kyle/Dropbox (GaTech)/projects/cleo, is identified as a symlink or child of a symlink, adjusting pytest paths accordingly.

2024-09-18 14:18:18.047 [error] ImportError while loading conftest '/home/kyle/GaTech Dropbox/Kyle Johnsen/projects/cleo/tests/conftest.py'.

2024-09-18 14:18:18.060 [error] tests/conftest.py:5: in <module>
    import brian2.only as b2
E   ModuleNotFoundError: No module named 'brian2'

2024-09-18 14:18:18.105 [error] Subprocess exited unsuccessfully with exit code 4 and signal null on workspace /home/kyle/Dropbox (GaTech)/projects/cleo.
2024-09-18 14:18:18.105 [error] Subprocess exited unsuccessfully with exit code 4 and signal null on workspace /home/kyle/Dropbox (GaTech)/projects/cleo. Creating and sending error discovery payload
2024-09-18 14:18:18.105 [error] pytest test discovery error for workspace:  /home/kyle/Dropbox (GaTech)/projects/cleo 
  
 The python test process was terminated before it could exit on its own, the process errored with: Code: 4, Signal: null for workspace /home/kyle/Dropbox (GaTech)/projects/cleo

Extension version: 2024.15.2024090406
VS Code version: Code - Insiders 1.94.0-insider (a162831, 2024-09-06T12:53:19.832Z)
OS version: Windows_NT x64 10.0.22631
Modes:
Remote OS version: Linux x64 5.15.153.1-microsoft-standard-WSL2

  • Python version (& distribution if applicable, e.g. Anaconda): 3.12.1
  • Type of virtual environment used (e.g. conda, venv, virtualenv, etc.): Conda
  • Value of the python.languageServer setting: Pylance
User Settings


languageServer: "Pylance"

testing
• pytestArgs: "<placeholder>"
• pytestEnabled: true
• autoTestDiscoverOnSaveEnabled: false

Installed Extensions
Extension Name Extension Id Version
autoDocstring - Python Docstring Generator njpwerner.autodocstring 0.6.1
C/C++ ms-vscode.cpptools 1.21.6
C/C++ Extension Pack ms-vscode.cpptools-extension-pack 1.3.0
CMake twxs.cmake 0.0.17
CMake Tools ms-vscode.cmake-tools 1.19.51
Code Spell Checker streetsidesoftware.code-spell-checker 3.0.1
Color Highlight naumovs.color-highlight 2.8.0
Even Better TOML tamasfe.even-better-toml 0.19.2
GitHub Copilot GitHub.copilot 1.229.1107
GitHub Copilot Chat GitHub.copilot-chat 0.21.2024091702
GitHub Pull Requests GitHub.vscode-pull-request-github 0.96.0
GitLens — Git supercharged eamodio.gitlens 2024.9.1705
HTML CSS Support ecmel.vscode-html-css 2.0.10
Insert Unicode brunnerh.insert-unicode 0.15.1
IntelliCode VisualStudioExptTeam.vscodeintellicode 1.3.1
IntelliCode API Usage Examples VisualStudioExptTeam.intellicode-api-usage-examples 0.2.8
JavaScript Debugger ms-vscode.js-debug 1.93.0
Jupyter ms-toolsai.jupyter 2024.9.2024091301
Jupyter Cell Tags ms-toolsai.vscode-jupyter-cell-tags 0.1.9
Jupyter Notebook Renderers ms-toolsai.jupyter-renderers 1.0.19
Jupyter Slide Show ms-toolsai.vscode-jupyter-slideshow 0.1.6
LaTeX Workshop James-Yu.latex-workshop 10.3.2
Live Preview ms-vscode.live-server 0.5.2024091601
Live Share ms-vsliveshare.vsliveshare 1.0.5940
Markdown Preview Enhanced shd101wyy.markdown-preview-enhanced 0.8.14
MATLAB MathWorks.language-matlab 1.2.5
MyST-Markdown ExecutableBookProject.myst-highlight 0.11.0
nbdev hamelhusain.nbdev 0.0.11
Path Intellisense christian-kohler.path-intellisense 2.9.0
Pylance ms-python.vscode-pylance 2024.9.1
Python ms-python.python 2024.14.1
Python Debugger ms-python.debugpy 2024.10.0
Quarto quarto.quarto 1.114.0
Rainbow CSV mechatroner.rainbow-csv 3.12.0
Ruff charliermarsh.ruff 2024.48.0
SVG jock.svg 1.5.4
Table Visualizer for JavaScript Profiles ms-vscode.vscode-js-profile-table 1.0.9
Tinymist Typst myriad-dreamin.tinymist 0.11.20
Typst LSP nvarner.typst-lsp 0.13.0
System Info
Item Value
CPUs Intel(R) Core(TM) i9-9980HK CPU @ 2.40GHz (16 x 2400)
GPU Status 2d_canvas: enabled
canvas_oop_rasterization: enabled_on
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: disabled_off
video_decode: enabled
video_encode: enabled
vulkan: disabled_off
webgl: enabled
webgl2: enabled
webgpu: enabled
webnn: disabled_off
Load (avg) undefined
Memory (System) 31.73GB (8.73GB free)
Process Argv --crash-reporter-id 13862219-8062-4bb8-969d-b654fdb7b5e1
Screen Reader no
VM 0%
Item Value
Remote WSL: Ubuntu-22.04
OS Linux x64 5.15.153.1-microsoft-standard-WSL2
CPUs Intel(R) Core(TM) i9-9980HK CPU @ 2.40GHz (16 x 0)
Memory (System) 15.49GB (11.67GB free)
VM 0%
A/B Experiments
vsliv368:30146709
vspor879:30202332
vspor708:30202333
vspor363:30204092
vscod805cf:30301675
vsaa593cf:30376535
py29gd2263:31024238
c4g48928:30535728
962ge761:30841072
pythongtdpath:30726887
welcomedialog:30812478
pythonnoceb:30776497
asynctok:30898717
dsvsc014:30777825
dsvsc015:30821418
pythonmypyd1:30859725
h48ei257:31000450
pythontbext0:30879054
accentitlementst:30870582
dsvsc016:30879898
dsvsc017:30880771
dsvsc018:30880772
cppperfnew:30980852
pythonait:30973460
724cj586:31013169
a69g1124:31018687
dvdeprecation:31040973
dwnewjupytercf:31046870
nb_pkg_only:31057982
nativerepl1:31134653
refactort:31084545
pythonrstrctxt:31093868
flighttreat:31119334
wkspc-onlycs-t:31132770
nativeloc1:31118317
wkspc-ranged-t:31125599
3ad50483:31111987
jh802675:31132134
e80f6927:31120813
fje88620:31121564
notype1:31136707
b50ed353:31138333
showchatpanel:31139797
f8igb616:31140137

Metadata

Metadata

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions