Test discovery failed (spawn pytest ENOENT)
See original GitHub issueEnvironment data
- VS Code version: 1.30.1
- Extension version (available under the Extensions sidebar): 2019.1.0
- OS and version: openSUSE Leap 15 (Linux 5.0.0-rc3)
- Shell: fish 2.7.1
- Python version (& distribution if applicable, e.g. Anaconda): 3.6.5, OS package
- Type of virtual environment used (N/A | venv | virtualenv | conda | …): virtualenv, managed by poetry
- Relevant/affected Python packages and their versions: pytest 4.2.0 (plugins: allure-pytest 2.5.5, pytest-benchmark 3.2.2, pytest-timeout 1.3.3)
Workspace structure
igor@juno [10:39:26] ~/s/pycloud> tree -L 2
.
├── poetry.lock
├── pyproject.toml
├── sce
│ ├── admin
│ ├── auth.py
│ ├── exceptions.py
│ ├── files.py
│ ├── __init__.py
│ ├── __pycache__
│ ├── security.py
│ ├── users.py
│ └── utils.py
├── setup.py
└── tests
├── backend
├── conftest.py
├── error.log
├── frontend
├── lib
├── performance
├── __pycache__
├── pytest.ini
├── README.md
├── requirements.txt
└── samples
Settings
User settings:
{
"window.zoomLevel": 0,
"files.autoSave": "afterDelay",
"editor.minimap.enabled": false,
"git.confirmSync": false,
"explorer.confirmDragAndDrop": false,
"workbench.statusBar.feedback.visible": false,
"python.linting.pylintUseMinimalCheckers": false,
"python.linting.pylintArgs": ["-d", "C0103"],
"editor.tabSize": 4,
"editor.detectIndentation": false,
"git.autofetch": true,
"java.jdt.ls.vmargs": "-noverify -Xmx1G -XX:+UseG1GC -XX:+UseStringDeduplication -javaagent:\"/home/igor/.vscode/extensions/gabrielbb.vscode-lombok-0.9.7/server/lombok.jar\" -Xbootclasspath/a:\"/home/igor/.vscode/extensions/gabrielbb.vscode-lombok-0.9.7/server/lombok.jar\"",
"git.enableSmartCommit": true,
"editor.renderWhitespace": "none",
"explorer.confirmDelete": false
}
Workspace settings:
{
"settings": {
"python.pythonPath": "/home/igor/.cache/pypoetry/virtualenvs/pycloud-py3.6/bin/python",
"files.exclude": {
// exclude python & pytest cache dirs
".pytest_cache": true,
"**/__pycache__": true,
".cache": true,
"allure": true
},
"python.unitTest.pyTestArgs": ["backend"],
"python.unitTest.cwd": "tests",
"python.unitTest.unittestEnabled": false,
"python.unitTest.nosetestsEnabled": false,
"python.unitTest.pyTestEnabled": true,
"python.unitTest.pyTestPath": "/home/igor/.cache/pypoetry/virtualenvs/pycloud-py3.6/bin/pytest",
"python.venvPath": "~/.cache/pypoetry/virtualenvs/",
}
}
Expected behaviour
VScode normally executes pytest-related commands from virtualenv.
Actual behaviour
Everything (like pylint, IntelliSense, go to definition etc) works fine except tests discover:
Test discovery error, please check the configuration settings for the tests. Path to the pytest test framework is invalid (/home/igor/.cache/pypoetry/virtualenvs/pycloud-py3.6/bin/pytest)
Although all paths exists and pytest works as charm from the command line:
igor@juno [10:39:07] ~/s/p/tests> pwd
/home/igor/<...>/pycloud/tests
igor@juno [10:45:14] ~/s/p/tests> /home/igor/.cache/pypoetry/virtualenvs/pycloud-py3.6/bin/pytest --version
This is pytest version 4.2.0, imported from /home/igor/.cache/pypoetry/virtualenvs/pycloud-py3.6/lib64/python3.6/site-packages/pytest.py
setuptools registered plugins:
pytest-timeout-1.3.3 at /home/igor/.cache/pypoetry/virtualenvs/pycloud-py3.6/lib64/python3.6/site-packages/pytest_timeout.py
pytest-benchmark-3.2.2 at /home/igor/.cache/pypoetry/virtualenvs/pycloud-py3.6/lib64/python3.6/site-packages/pytest_benchmark/plugin.py
allure-pytest-2.5.5 at /home/igor/.cache/pypoetry/virtualenvs/pycloud-py3.6/lib64/python3.6/site-packages/allure_pytest/plugin.py
igor@juno [10:45:18] ~/s/p/tests> /home/igor/.cache/pypoetry/virtualenvs/pycloud-py3.6/bin/pytest backend/ --collect-only
=============================================================================================== test session starts ================================================================================================
platform linux -- Python 3.6.5, pytest-4.2.0, py-1.7.0, pluggy-0.8.1
benchmark: 3.2.2 (defaults: timer=time.perf_counter disable_gc=False min_rounds=5 min_time=0.000005 max_time=1.0 calibration_precision=10 warmup=False warmup_iterations=100000)
rootdir: /home/igor/<...>/pycloud/tests, inifile: pytest.ini
plugins: timeout-1.3.3, benchmark-3.2.2, allure-pytest-2.5.5
timeout: 30.0s
timeout method: signal
timeout func_only: False
collected 72 items
Steps to reproduce:
=/
Logs
Output for Python
in the Output
panel (View
→Output
, change the drop-down the upper-right of the Output
panel to Python
)
Python test log:
Test Discovery failed:
Error: spawn /home/igor/.cache/pypoetry/virtualenvs/pycloud-py3.6/bin/pytest ENOENT
Test Discovery failed:
Error: spawn /home/igor/.cache/pypoetry/virtualenvs/pycloud-py3.6/bin/pytest ENOENT
Test Discovery failed:
Error: spawn /home/igor/.cache/pypoetry/virtualenvs/pycloud-py3.6/bin/pytest ENOENT
Python log:
Starting Jedi Python language engine.
##########Linting Output - pylint##########
<...>
------------------------------------------------------------------
Your code has been rated at 8.95/10 (previous run: 8.95/10, +0.00)
##########Linting Output - pylint##########
##########Linting Output - pylint##########
************* Module lib.settings
<...>
Output from Console
under the Developer Tools
panel:
There is a lot of stuff, so I attached it as a file:
js-console.log
Issue Analytics
- State:
- Created 5 years ago
- Comments:10
Top Results From Across the Web
Test discovery failed (spawn pytest ENOENT) #4261 - GitHub
VScode normally executes pytest-related commands from virtualenv. Actual behaviour. Everything (like pylint, IntelliSense, go to definition etc) ...
Read more >VSCode on discover tests Error: spawn python ENOENT
ENOENT Generally means that it's an invalid path, but the path seems perfectly fine. $echo $PATH /Users/<username>/apps/project/venv/bin.
Read more >VSCode on discover tests Error: spawn python ... - 七牛云
移除 pytest.testing.cwd 并重新加载VSCode,它也清除了我的问题--谢谢你,这个建议非常有效。 看起来VScode设置会被缓存,即使它们看起来已经被更新。 Petr Szturc:.
Read more >How to fix this Error: spawn EACCES - Edward Beazer Blog
This error comes up when you don't have full permissions to the project folder. You want to run the chmod command in order...
Read more >Error: spawn /usr/pgadmin4/venv/bin/python3 ENOENT - Ask ...
I have handle the error to switch pyhton3.10 to python3.9 and error fixed. Just track the steps: Install python3.9 Switch 3.10 to 3.9....
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Ok. Looks like I found the root cause: there was two
python.pythonPath
settings – one in workspace settings and another in .vscode/settings.json. Once I removed settings from workspace config, tests discover works as charm.Thank you for the environment hint, and thank you for the Python support in vscode!
Unfortunately I’m going to have to close this as it works in other environment for you, i.e. it’s an environment related issue, something we have little to no control over.