简体   繁体   English

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

[英]VSCode doesn't show poetry virtualenvs in select interpreter option

I need help.我需要帮助。 VSCode will NEVER find poetry virtualenv interpreter no matter what I try.无论我尝试什么,VSCode 都不会找到诗歌 virtualenv 解释器。

Installed poetry Python package manager using a standard $ curl method as explained in the official documentation .使用标准的$ curl方法安装了诗歌 Python 包管理器,如官方文档中所述

Started a project by $ poetry new finance-essentials_37-64 , installed poetry environment with $ poetry install .$ poetry new finance-essentials_37-64启动了一个项目,用$ poetry install安装了诗歌环境。

So now I can see that I indeed have a virtual environment by:所以现在我可以通过以下方式看到我确实有一个虚拟环境:

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

and this virtualenv is installed at: C:\\Users\\Jaepil\\AppData\\Local\\pypoetry\\Cache\\virtualenvs , which has finance-essentials-37-64-SCQrHB_N-py3.7 directory.并且这个 virtualenv 安装在: C:\\Users\\Jaepil\\AppData\\Local\\pypoetry\\Cache\\virtualenvs ,其中有finance-essentials-37-64-SCQrHB_N-py3.7目录。

However, VSCode is unable to find this virtualenv in its 'select interpreter' command.但是,VSCode 无法在其“选择解释器”命令中找到此 virtualenv。 I only see a bunch of Anaconda and Pipenv environments but not the poetry environment's interpreter that I've just made.我只看到一堆 Anaconda 和 Pipenv 环境,但没有看到我刚刚制作的诗歌环境的解释器。

I also added "python.venvPath": "~/.cache/pypoetry/virtualenvs", to my settings.json as suggested in here , but to no avail.我还按照此处的建议将"python.venvPath": "~/.cache/pypoetry/virtualenvs",到我的settings.json中,但无济于事。 Still doesn't work.还是不行。

I also tried an absolute path, by adding "python.venvPath": "C:\\\\Users\\\\Jaepil\\\\AppData\\\\Local\\\\pypoetry\\\\Cache\\\\virtualenvs", to the same settings, but it also doesn't work.我还尝试了绝对路径,方法是将"python.venvPath": "C:\\\\Users\\\\Jaepil\\\\AppData\\\\Local\\\\pypoetry\\\\Cache\\\\virtualenvs",到相同的设置中,但它也没有不行。

VSCode settings reference states that it has python.poetryPath as a default but it doesn't seem to work either.VSCode 设置参考指出它有python.poetryPath作为默认值,但它似乎也不起作用。 Should I change the default value "poetry" in this case?在这种情况下,我应该更改默认值"poetry"吗?

python.poetryPath python.poetryPath

"poetry" “诗歌”

Specifies the location of the Poetry dependency manager executable, if installed.指定 Poetry 依赖管理器可执行文件的位置(如果已安装)。 The default value "poetry" assumes the executable is in the current path.默认值“poetry”假定可执行文件在当前路径中。 The Python extension uses this setting to install packages when Poetry is available and there's a poetry.lock file in the workspace folder. Python 扩展使用此设置在 Poetry 可用且工作区文件夹中有一个诗歌.lock 文件时安装包。

I'm on Windows 10 pro 64bit & Has Python 3.7.6 installed on the system.我使用的是 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

I need help.我需要帮助。 VSCode will NEVER find poetry virtualenv interpreter no matter what I try.不管我尝试什么,VSCode都永远找不到诗歌virtualenv解释器。

Installed poetry Python package manager using a standard $ curl method as explained in the official documentation .官方文档中所述,使用标准的$ curl方法安装了诗歌Python软件包管理器。

Started a project by $ poetry new finance-essentials_37-64 , installed poetry environment with $ poetry install .$ poetry new finance-essentials_37-64开始一个项目,并在$ poetry install安装了诗歌环境。

So now I can see that I indeed have a virtual environment by:现在,我可以通过以下方式看到我确实有一个虚拟环境:

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

and this virtualenv is installed at: C:\\Users\\Jaepil\\AppData\\Local\\pypoetry\\Cache\\virtualenvs , which has finance-essentials-37-64-SCQrHB_N-py3.7 directory.并将此virtualenv安装在以下位置: C:\\Users\\Jaepil\\AppData\\Local\\pypoetry\\Cache\\virtualenvs ,该目录具有finance-essentials-37-64-SCQrHB_N-py3.7目录。

However, VSCode is unable to find this virtualenv in its 'select interpreter' command.但是,VSCode无法在其“选择解释器”命令中找到此virtualenv。 I only see a bunch of Anaconda and Pipenv environments but not the poetry environment's interpreter that I've just made.我只看到一堆Anaconda和Pipenv环境,但没有看到我刚才制作的诗歌环境的解释器。

I also added "python.venvPath": "~/.cache/pypoetry/virtualenvs", to my settings.json as suggested in here , but to no avail.我还按照此处的建议在我的settings.json添加了"python.venvPath": "~/.cache/pypoetry/virtualenvs", ,但无济于事。 Still doesn't work.仍然不起作用。

I also tried an absolute path, by adding "python.venvPath": "C:\\\\Users\\\\Jaepil\\\\AppData\\\\Local\\\\pypoetry\\\\Cache\\\\virtualenvs", to the same settings, but it also doesn't work.我还尝试了一个绝对路径,方法是将"python.venvPath": "C:\\\\Users\\\\Jaepil\\\\AppData\\\\Local\\\\pypoetry\\\\Cache\\\\virtualenvs",添加到相同的设置中"python.venvPath": "C:\\\\Users\\\\Jaepil\\\\AppData\\\\Local\\\\pypoetry\\\\Cache\\\\virtualenvs", ,但它也没有不行

VSCode settings reference states that it has python.poetryPath as a default but it doesn't seem to work either.VSCode设置参考指出其默认值为python.poetryPath ,但似乎也不起作用。 Should I change the default value "poetry" in this case?在这种情况下,我应该更改默认值"poetry"吗?

python.poetryPath 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.默认值“ poetry”假定可执行文件在当前路径中。 The Python extension uses this setting to install packages when Poetry is available and there's a poetry.lock file in the workspace folder.当可用诗歌并且在工作空间文件夹中有poetry.lock文件时,Python扩展程序将使用此设置来安装软件包。

I'm on Windows 10 pro 64bit & Has Python 3.7.6 installed on the system.我在Windows 10专业版64位系统上,并在系统上安装了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

I need help.我需要帮助。 VSCode will NEVER find poetry virtualenv interpreter no matter what I try.不管我尝试什么,VSCode都永远找不到诗歌virtualenv解释器。

Installed poetry Python package manager using a standard $ curl method as explained in the official documentation .官方文档中所述,使用标准的$ curl方法安装了诗歌Python软件包管理器。

Started a project by $ poetry new finance-essentials_37-64 , installed poetry environment with $ poetry install .$ poetry new finance-essentials_37-64开始一个项目,并在$ poetry install安装了诗歌环境。

So now I can see that I indeed have a virtual environment by:现在,我可以通过以下方式看到我确实有一个虚拟环境:

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

and this virtualenv is installed at: C:\\Users\\Jaepil\\AppData\\Local\\pypoetry\\Cache\\virtualenvs , which has finance-essentials-37-64-SCQrHB_N-py3.7 directory.并将此virtualenv安装在以下位置: C:\\Users\\Jaepil\\AppData\\Local\\pypoetry\\Cache\\virtualenvs ,该目录具有finance-essentials-37-64-SCQrHB_N-py3.7目录。

However, VSCode is unable to find this virtualenv in its 'select interpreter' command.但是,VSCode无法在其“选择解释器”命令中找到此virtualenv。 I only see a bunch of Anaconda and Pipenv environments but not the poetry environment's interpreter that I've just made.我只看到一堆Anaconda和Pipenv环境,但没有看到我刚才制作的诗歌环境的解释器。

I also added "python.venvPath": "~/.cache/pypoetry/virtualenvs", to my settings.json as suggested in here , but to no avail.我还按照此处的建议在我的settings.json添加了"python.venvPath": "~/.cache/pypoetry/virtualenvs", ,但无济于事。 Still doesn't work.仍然不起作用。

I also tried an absolute path, by adding "python.venvPath": "C:\\\\Users\\\\Jaepil\\\\AppData\\\\Local\\\\pypoetry\\\\Cache\\\\virtualenvs", to the same settings, but it also doesn't work.我还尝试了一个绝对路径,方法是将"python.venvPath": "C:\\\\Users\\\\Jaepil\\\\AppData\\\\Local\\\\pypoetry\\\\Cache\\\\virtualenvs",添加到相同的设置中"python.venvPath": "C:\\\\Users\\\\Jaepil\\\\AppData\\\\Local\\\\pypoetry\\\\Cache\\\\virtualenvs", ,但它也没有不行

VSCode settings reference states that it has python.poetryPath as a default but it doesn't seem to work either.VSCode设置参考指出其默认值为python.poetryPath ,但似乎也不起作用。 Should I change the default value "poetry" in this case?在这种情况下,我应该更改默认值"poetry"吗?

python.poetryPath 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.默认值“ poetry”假定可执行文件在当前路径中。 The Python extension uses this setting to install packages when Poetry is available and there's a poetry.lock file in the workspace folder.当可用诗歌并且在工作空间文件夹中有poetry.lock文件时,Python扩展程序将使用此设置来安装软件包。

I'm on Windows 10 pro 64bit & Has Python 3.7.6 installed on the system.我在Windows 10专业版64位系统上,并在系统上安装了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

You can add your virtualenvs folder to "python.venvFolders" in vs code global settings.您可以在 vs 代码全局设置中将您的 virtualenvs 文件夹添加到"python.venvFolders"

Like that for Windows:就像 Windows 一样:

"python.venvFolders": [
    "C:\\Users\\User\\AppData\\Local\\pypoetry\\Cache\\virtualenvs\\"
  ]

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM