简体   繁体   English

vscode 似乎没有激活我的虚拟 python 环境

[英]vscode doesn't seem to activate my virtual python environment

I have some python code that I wrote and have just installed vscode and starting to work with it.我有一些我编写的 python 代码,并且刚刚安装了 vscode 并开始使用它。

the code is in home/user/code/dlS3BMC folder which has a env folder with my virtual environment.代码位于 home/user/code/dlS3BMC 文件夹中,其中有一个包含我的虚拟环境的 env 文件夹。 I am using Linux Mint 19.3 Tricia cinnamon desktop, vscode 1.41.1我正在使用 Linux Mint 19.3 Tricia cinnamon 桌面,vscode 1.41.1

I open this folder in vscode.我在 vscode 中打开这个文件夹。 ctrl+ shft+p and I see my virtual environment, I select it, but when I do which python in the terminal window it is still pointing to the system python /usr/bin/python ctrl+ shft+p 我看到了我的虚拟环境,我选择了它,但是当我在终端窗口中执行 which python 时它仍然指向系统 python /usr/bin/python

If I .如果我 。 env/bin/activate in the terminal everything works fine - I don't mind doing that but it would be nice if I didn't have to. env/bin/activate 在终端中一切正常 - 我不介意这样做,但如果我不必这样做会很好。

From the microsoft docs I think it is supposed to automatically activate the env, but it does not.从 microsoft docs 我认为它应该自动激活 env,但它没有。 I have tried saving project after I activate, but when I close and open again, it is not activated.我在激活后尝试保存项目,但是当我关闭并再次打开时,它没有被激活。 Sorry I am very new to vscode at this stage and have just used sublime text editor to write my python code in the past.抱歉,我在现阶段对 vscode 还很陌生,过去刚刚使用 sublime 文本编辑器编写了我的 python 代码。

Thanks Bill谢谢比尔

ok, it seems it does not activate the virtual environment until you run the code either debug or simply run... when you run the code, I can see it activate the env.好的,它似乎不会激活虚拟环境,直到您运行代码调试或只是运行...当您运行代码时,我可以看到它激活了环境。

TIL this.直到这个。

Regards Bill问候比尔

This is a known issue in VS Code (still... nearly 2 years later).这是 VS Code 中的一个已知问题(仍然......近 2 年后)。 If you would like to see it fixed, you can give the VSCode Github issue a "thumbsup".如果你想看到它被修复,你可以给VSCode Github 问题一个“拇指”。 If it reaches 20 before Jan 10th, it'll be added to their development roadmap如果在 1 月 10 日之前达到 20,它将被添加到他们的发展路线图

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

相关问题 python workon 命令未激活 cmd windows 中的虚拟环境 7 - python workon command doesn't activate the virtual environment in cmd windows 7 用厨师激活python虚拟环境 - activate python virtual environment with chef 每次我重新启动我的vscode Django时是否需要激活Django虚拟环境 - Is it necessary to activate Django Virtual Environment every time i restart my vscode Django 为什么我无法使用“source env/bin/activate”命令激活我的虚拟 Python 环境? - How come I can not activate my Virtual Python Environment with 'source env/bin/activate' command? Python 解释器(VScode)“激活”一个 conda 环境,但环境没有改变 - Python interpreter (VScode) "activates" a conda environment, but the environment doesn't change 系统禁用运行脚本时,如何在Vscode中激活虚拟环境? - How to activate virtual environment in Vscode when running scripts are disabled in system? 无法在Miniconda中激活虚拟环境 - Can't activate virtual environment in Miniconda 虚拟环境不会在 Windows 10 上激活 - Virtual Environment won't activate on Windows 10 Python在不更改提示的情况下激活虚拟环境 - Python activate virtual environment without changing prompt 从 python 脚本激活虚拟环境 - Activate virtual environment from a python script
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM