python - VSCode 在选择解释器选项中不显示诗歌虚拟环境

标签 python visual-studio-code python-poetry

我需要帮助。无论我尝试什么,VSCode 都不会找到诗歌 virtualenv 解释器。

使用标准 $ curl 安装了诗歌 Python 包管理器方法如解释 in the official documentation .

通过 $ poetry new finance-essentials_37-64 开始了一个项目,用$ poetry install安装诗歌环境.

所以现在我可以通过以下方式看到我确实有一个虚拟环境:

Jaepil@Jaepil-PC MINGW64 /e/VSCodeProjects/finance_essentials_37-64 $ poetry env list 
>> finance-essentials-37-64-SCQrHB_N-py3.7 (Activated)

这个 virtualenv 安装在:C:\Users\Jaepil\AppData\Local\pypoetry\Cache\virtualenvs ,其中有 finance-essentials-37-64-SCQrHB_N-py3.7目录。

但是,VSCode 无法在其“选择解释器”命令中找到此 virtualenv。我只看到一堆 Anaconda 和 Pipenv 环境,但没有看到我刚刚制作的诗歌环境的解释器。

我还加了 "python.venvPath": "~/.cache/pypoetry/virtualenvs",到我的 settings.json正如 here 中所建议的,但无济于事。
还是不行。

我也尝试了绝对路径,添加 "python.venvPath": "C:\\Users\\Jaepil\\AppData\\Local\\pypoetry\\Cache\\virtualenvs",到相同的设置,但它也不起作用。

VSCode settings reference声明它有 python.poetryPath作为默认设置,但它似乎也不起作用。我应该更改默认值 "poetry"在这种情况下?

python.poetryPath

"poetry"

Specifies the location of the Poetry dependency manager executable, if installed. The default value "poetry" assumes the executable is in the current path. The Python extension uses this setting to install packages when Poetry is available and there's a poetry.lock file in the workspace folder.



我使用的是 64 位 Windows 10 专业版并在系统上安装了 Python 3.7.6。
PS C:\Users\Jaepil> python
Python 3.7.6 (tags/v3.7.6:43364a7ae0, Dec 19 2019, 00:42:30) [MSC v.1916 64 bit (AMD64)] on win32

最佳答案

您需要设置"python.venvPath": "C:\\Users\\Jaepil\\AppData\\Local\\pypoetry\\Cache\\virtualenvs"在您的设置中(您尝试的那个是针对 UNIX 的)。

你也可以👍 https://github.com/microsoft/vscode-python/issues/8372帮助优先为 Python 扩展添加 Poetry 虚拟环境支持。

关于python - VSCode 在选择解释器选项中不显示诗歌虚拟环境,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59882884/

相关文章:

rasa - 发现的虚拟环境似乎已损坏| python诗歌

附加到列表的 Python 日志记录处理程序

python -/urlchecker/http ://www. google.com 的正则表达式是什么

python - 有没有办法在 Tornado 中发送 "lock"请求,直到完成某些操作?

visual-studio-code - Visual Studio Code files.exclude 设置不起作用

asp.net-core - 在当前目录中找不到 'project.json' - .NET Core Webapp 调试

c++ - 获取 vscode c++ 插件以定位 Protocol Buffer header

anaconda3 - 诗歌安装不会使用 Anaconda python 3.9 env 在项目文件夹中创建 .env 文件夹

python - 如何安装带有诗歌的 python 包?

python - R 相当于 numpy 'frombuffer'