在 Ubuntu 中将 virtualenv 与 Python 与 Visual Studio Code 结合使用 [英] Use virtualenv with Python with Visual Studio Code in Ubuntu

查看:28
本文介绍了在 Ubuntu 中将 virtualenv 与 Python 与 Visual Studio Code 结合使用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个 Python 项目,并且导航/自动完成在项目的文件中完美运行.我想指定一个 virtualenv 以便导航/自动完成与该 virtualenv 中的包一起使用.>

我在 settings.py 中试过这个,但导航/自动完成不起作用.同样通过设置 "python.pythonPath":"~/dev/venvs/proj/bin/python 杀死了原来的导航/自动完成.

<代码>{editor.rulers":[80,100],python.autoComplete.extraPaths":[~/dev/venvs/proj",~/dev/venvs/proj/lib"]}

解决方案

使用最新的 更新扩展 您需要做的只是指定"python.pythonPath" 如下.

"python.autoComplete.extraPaths" 的值将在运行时确定,但您仍然可以在其中自由指定自定义路径.

请记得在进行必要的更改后重新启动 Visual Studio Code.

<代码>{editor.rulers":[80,100],python.pythonPath":~/dev/venvs/proj/bin/python"}

I have a Python project and navigation/autocomplete work perfectly within files in the project. I want to specify a virtualenv so that navigation/autocomplete work with packages inside that virtualenv.

I tried this in settings.py, but navigation/autocomplete does not work. Also by setting "python.pythonPath":"~/dev/venvs/proj/bin/python killed the original navigation/autocomplete.

{
    "editor.rulers": [80,100],
    "python.autoComplete.extraPaths": [
        "~/dev/venvs/proj",
        "~/dev/venvs/proj/lib"
     ]
}

解决方案

With the latest update to the extension all you need to do is just specify the "python.pythonPath" as follows.

The values for "python.autoComplete.extraPaths" will be determined during runtime, but you are still free to specify custom paths in there.

Please, remember to restart Visual Studio Code once the necessary changes have been made.

{
    "editor.rulers": [80,100],
    "python.pythonPath":"~/dev/venvs/proj/bin/python"
}

这篇关于在 Ubuntu 中将 virtualenv 与 Python 与 Visual Studio Code 结合使用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆