Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I remove unused packages from virtualenv?

How can I keep track of the packages when I install them using pip inside a virtualenv?

It seems like a mess now; if I install package A, it automatically install its dependancies; B, C and D. Then I decide to use package N instead which installs its dependancies as well.

Now when I remove package A, its dependancies are not automatically removed.

How I can keep my virtualenv clean? Is there a tool to check for unused packages and remove them?

like image 401
Adam Silver Avatar asked Oct 26 '13 16:10

Adam Silver


Video Answer


1 Answers

To remove a package:

pip uninstall package_name

To get list of packages required by any given package (using pip):

pip show package_name

This will show you the packages that are required for it to run, and also the packages that require your package for them to run.

So the best way to uninstall a package with all its dependency packages is to run pip show package_name first to see the list of its dependency packages and then uninstall it along with its dependency packages one by one. For example:

pip show package_name
pip uninstall package_name
pip uninstall dependency_package_1
pip uninstall dependency_package_2

...etc

like image 189
Fouad Boukredine Avatar answered Oct 26 '22 13:10

Fouad Boukredine