Python: How do you check what is in virtualenv?

Viewed 30318

How do you check what package and version are installed inside virtualenv? My thought was to create requirement.txt file. But, is there another way to do this from CLI?

2 Answers

Once you activate your virtual environment, you should be able to list out packages using pip list and verify version using python --version.

pip list will show you all the packages that are installed for the virtualenv. I see you are wanting to create the requirements.txt file from a CLI, so you can run this command

pip freeze > requirements.txt

This will give you a requirements.txt file inside your current directory, for ALL the packages and libraries that are installed for that virtualenv.

Personally, I like using pigar. All you need to do after installing it is run pigar and it will search through your Python files inside the current directory and create a requirements.txt file for you based on all your imports from those files.

Related