简体   繁体   中英

Where is python interpreter located in virtualenv?

Where is python intrepreter located in virtual environment?

I am making a GUI project and I stuck while finding the python interpreter in my virtual environment.

python 解释器位于虚拟环境中的哪里?

Execute next code and it will print location of your python interpreter.

import sys
print(sys.executable)

To a lot of extents, it depends on how the virtual environment was created. If you installed like this py -m venv env then you would find it here .\\env\\Scripts\\activate . How ever if you created the environment using conda then you would find it here Anaconda_installation_folder/envs/name_of_environment . SO brief answer to your question, you would find it withing you env folder.

If you want to automatically active virtual env or (venv). Try this.

Install virtual env

python3 -m venv venv

If you have already have venv present. you can refer use this to get the executable python3 file like this.

#referred @Arty answer above.

import sys
print(sys.executable)

this will print the python3 path of that venv.

later open command pallet ( ctrl + shift + P ) and type python as shown in image.

在此处输入图像描述

Then click on

在此处输入图像描述

and paste that path into the input box.

Now the setup is done. Now every time you open a terminal, it will automatically open your terminal in the virtual env, and will auto-run the virtual env for you.

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