I am running a python project in vscode with virtualenv
. Python interpreter is set right. When I'm trying to discover tests it gives me an error saying
python /Users/user/.vscode/extensions/ms-python.python-2019.10.44104/pythonFiles/testing_tools/run_adapter.py discover pytest -- -s project/
Test Discovery failed:
Error: spawn /Users/<username>/apps/project/venv/bin/python ENOENT
My vscode settings.json looks something like this and I haven't configured launch.json
{
"python.pythonPath": "/Users/<username>/apps/project/venv/bin/python",
"python.testing.unittestEnabled": false,
"python.testing.nosetestsEnabled": false,
"python.testing.pytestEnabled": true,
"python.testing.pytestArgs": [
"project"
],
}
When I just type /Users/<username>/apps/project/venv/bin/python
on terminal python shell opens up.
ENOENT Generally means that it's an invalid path, but the path seems perfectly fine.
$echo $PATH
/Users/<username>/apps/project/venv/bin
I just ran into the same issue and found that it was due to a non-existing folder in the python.testing.cwd
setting where I used workspaceDir
instead of workspaceFolder
as a variable
Note that it seems to require restarting VSCode before a change here has any effect, i.e. if you change it to the wrong value it will seemingly continue to work but after a restart you'll get ENOENT and vice-versa
It resolved itself after I deleted the local .vscode folder inside the project, saved the workspace, and created a new .vscode/settings.json containing the testing settings. That seems to have fixed it.
Source: https://github.com/microsoft/vscode-python/issues/5316
Adding "python.testing.cwd": "${workspaceFolder}"
to settings.json
solved the issue for me.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With