要在VScode中使用Python的virtualenv虚拟环境,首先在设置同添加虚拟环境所在目录和虚拟环境的识别规则: { ... python.venvPath: E:\\envs, python.venvFolders: [ envs, .pyenv, .direnv, .env ]} 虚拟环境是通过名

要在VScode中使用Python的virtualenv虚拟环境,首先在设置同添加虚拟环境所在目录和虚拟环境的识别规则:
{ ... "python.venvPath": "E:\\envs", "python.venvFolders": [ "envs", ".pyenv", ".direnv', ".env" ]}
虚拟环境是通过名称识别的,例如在E:\envs目录下django_env, flash_env就不被".env"识别到.
重启下VScode设置才生效。
之后当你想要切换虚拟环境的时候只需要通过命令面板Python: Select Interpreter就会列出所有的虚拟环境。
推荐学习:vscode教程
以上就是vscode怎么使用虚拟环境的详细内容,更多请关注自由互联其它相关文章!