简体   繁体   中英

Is there a way to list all python virtual environments created using the venv module?

Conda allows me to list all virtual environments as shown here. The commands are:

conda info --envs OR conda env list  

I want to do that using pip. Does pip have any option to list all virtual environments created by me? I have created a virtual environment on my desktop but I cannot figure out a way to list it along with the base environment.

No, not in an easy way.

Python virtual environments can be stored anywhere on the disk. And AFAIK they are not indexed, they are truely isolated (after all you can just remove venv directory and be done with it, you don't need to do anything special). So that would require entire disk scan. Which potentially can be done (you can search for all Python executables for example) but is rather painful.

It works with Conda because Conda places venvs in concrete path, eg /home/username/miniconda/envs/ .

The virtual environment is always going to be in the directory you are working with. all you need is to open it and activate the script. That's all

One indirect way is to run below command and see the directories where the python executable resides. Some of the paths will be python virtual environments and you can verify it by listing the files in those paths.

$ whereis python

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