Monday, September 5, 2022

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

Issue

Conda allows me to list all virtual environments rel="nofollow noreferrer">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.


Solution

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, e.g. /home/username/miniconda/envs/.



Answered By - freakish
Answer Checked By - Pedro (WPSolving Volunteer)