【问题标题】:Configure Python Path in Visual Studio Code with venv running from bash on Windows使用从 Windows 上的 bash 运行的 venv 在 Visual Studio Code 中配置 Python 路径
【发布时间】:2017-11-17 03:03:29
【问题描述】:

我在 bash 中为 Windows (Ubuntu) 设置了一个虚拟环境,并安装了 VS Code (Windows)。 Python 项目在 bash 的 venv 中运行良好,但我现在想通过 Visual Code 对其进行调试。

我正在尝试在 settings.json 中设置 python.pythonPath 如下

{
    "python.pythonPath": "C:\\repos\\myrepo\\venv\\bin\\python"
}

返回的错误是“请验证路径...”

请注意,通过 Windows 的 bash,可以通过 /mnt/c/ 访问文件系统

至于Python的自动检测,它只列出了安装在windows文件系统上的python.exe(这对我没有用)。

https://code.visualstudio.com/docs/python/environments 解释说这样做就足够了,但似乎不起作用。

【问题讨论】:

    标签: python visual-studio-code windows-subsystem-for-linux virtual-environment


    【解决方案1】:

    它不起作用,因为从 0.8.0 版开始,扩展还没有正式支持 WSL。请参阅 https://github.com/Microsoft/vscode-python/issues/67 投票并跟踪检测基于 WSL 的虚拟环境的问题。

    【讨论】:

    • 这有什么更新吗?我已经在 settings.json 中设置了我的 python 路径:“python.pythonPath”:“env/bin/python”,但是我仍然遇到奇怪的 lint 错误,这些错误不是实际问题,我认为路径可能仍然不是正确设置
    • 我们通过 Remote - WSL 扩展支持 WSL(我个人一直使用它)。如果您遇到 linting 错误,那么您的环境将被拾取以运行 linter。
    • 我能够让它工作。我想我错过了 WSL 远程扩展。
    猜你喜欢
    • 2021-04-28
    • 1970-01-01
    • 2017-11-23
    • 1970-01-01
    • 2018-06-09
    • 2018-03-25
    • 1970-01-01
    • 2017-07-25
    • 2017-07-03
    相关资源
    最近更新 更多