简体   繁体   中英

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.

the code is in home/user/code/dlS3BMC folder which has a env folder with my virtual environment. I am using Linux Mint 19.3 Tricia cinnamon desktop, vscode 1.41.1

I open this folder in 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

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.

From the microsoft docs I think it is supposed to automatically activate the env, but it does not. 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.

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). If you would like to see it fixed, you can give the VSCode Github issue a "thumbsup". If it reaches 20 before Jan 10th, it'll be added to their development roadmap

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM