gpt4 book ai didi

python - Visual Studio Code - 如何向 python 路径添加多个路径?

转载 作者:太空狗 更新时间:2023-10-29 17:02:56 60 4
gpt4 key购买 nike

我正在尝试使用 Visual Studio Code,到目前为止,它看起来很棒(轻便、快速等)。

我正在尝试运行我的一个 Python 应用程序,它使用虚拟环境,但也使用不在我的虚拟环境的站点包中的库。

我知道在 settings.json 中,我可以指定一个 python.pythonPath 设置,我已经完成并指向一个虚拟环境。

我还知道我可以向 python.autoComplete.extraPaths 添加额外的路径,到目前为止我正在添加外部库。问题是,当我调试时,它失败了,因为它没有找到 python.autoComplete.extraPaths 中指定的库。

为此必须使用其他设置吗?

谢谢

最佳答案

这对我有用:-

在您的 launch.json 配置文件条目中,指定一个名为“env”的新条目,并自行设置 PYTHONPATH。

"configurations": [
{
"name": "Python",
"type": "python",
"stopOnEntry": false,
"request": "launch",
"pythonPath": "${config.python.pythonPath}",
"program": "${file}",
"cwd": "${workspaceRoot}",
"debugOptions": [
"WaitOnAbnormalExit",
"WaitOnNormalExit",
"RedirectOutput"
],
"env": {
"PYTHONPATH": "/path/a:path/b"
}
}
]

关于python - Visual Studio Code - 如何向 python 路径添加多个路径?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41471578/

60 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com