发现测试错误的VSCode错误:生成python ENOENT

我正在用virtualenv在vscode中运行一个python项目。 Python解释器已正确设置。当我尝试发现测试时,它会提示我一个错误

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

我的vscode settings.json看起来像这样,但我尚未配置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"
    ],}

当我在终端python shell上输入/Users/<username>/apps/project/venv/bin/python时打开。

ENOENT通常表示这是无效路径,但该路径看起来很正常。

$echo $PATH
/Users/<username>/apps/project/venv/bin
zhangyansong 回答:发现测试错误的VSCode错误:生成python ENOENT

  

在我删除了本地.vscode文件夹后,它自行解决   项目,保存工作区,并创建一个新的.vscode / settings.json   包含测试设置。看来已经解决了。

来源:https://github.com/microsoft/vscode-python/issues/5316

,

仍然不知道确切的问题是什么,但是,我从笔记本电脑中删除了所有vscode痕迹。从头开始重新安装就可以了。

,

我遇到了同样的问题,并通过确保已清除所有settings.json文件(用户,工作区以及可能的docker容器)中的python.testing。*条目来解决此问题。

,

我只是遇到了同样的问题,发现这是由于在python.testing.cwd设置中不存在的文件夹导致我使用workspaceDir而不是workspaceFolder作为变量>

请注意,似乎需要重新启动VSCode才能在此处生效,例如,如果将其更改为错误的值,它似乎将继续起作用,但是在重新启动后,您将获得ENOENT,反之亦然

本文链接:https://www.f2er.com/3124860.html

大家都在问