python - vscode找不到带诗和wsl的python

标签 python visual-studio-code python-poetry

我想通过 WSL 在 vscode 中使用 poetry “创建”的 python interperter,但是 vscode 中没有显示正确的 python 版本。

我在 WSL 终端中运行以下命令:

$ poetry shell
Spawning shell within /home/kwint/.cache/pypoetry/virtualenvs/metal-hub-python-py3.7
$ code .

在 vscode 中发现的唯一interperter 是在/usr/ 中的。我试过手动输入 virtualenv 的路径但没有运气。这是 which python 返回的路径:/home/kwint/.cache/pypoetry/virtualenvs/metal-hub-python-py3.7/bin/python

最佳答案

您可以手动指定 "python.pythonPath"/home/kwint/.cache/pypoetry/virtualenvs/metal-hub-python-py3.7/bin/python 或尝试将 "python.venvPath" 设置为 /home/kwint/.cache/pypoetry/virtualenvs,这应该会检测到所有由 Poetry 创建的虚拟环境。

另外,请 👍 feature request to detect Poetry virtual environments如果您想获得官方支持。

关于python - vscode找不到带诗和wsl的python,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58935198/

相关文章:

python - 无法从 pygal.maps.world.COUNTRIES 中提取国家/地区代码

python - 仅将列的 float 转换为整数

python - 无法使用python在dbus中调用klipper方法

php - 如何为 VS Code 中删除的 mysql_* 函数添加智能感知

python - 诗歌: how to reinstall a wheel with the same name

python - 如何在 Python 中打印到 stderr?

visual-studio-code - 如何从 Rust-analyzer 自动完成中隐藏关键字?

python - Windows 中的 Poetry 安装不起作用

Python 诗歌无法克隆验证远程上是否存在引用

visual-studio-code - Visual Studio Code 禁用自动关闭标签