Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Virtualenv - Cleaning up unused package installations

So I have been developing my first django web application over the past few months and I have installed a number of packages that I wanted to try and use to solve some of my problems. However, some of these packages I installed, tried to use, failed, and then never uninstalled.

Is there a way to see what packages my application is using from the list given from "pip freeze"?

That way I can uninstall some of the clutter in my application. Is it a huge disadvantage to have this clutter?

In future development I will uninstall packages right away if I do not use them. So lesson learned :).

like image 814
Programmingjoe Avatar asked Nov 26 '25 13:11

Programmingjoe


1 Answers

A method I use is with my requirements.txt files. From the root of my Django project, I create a requirements/ directory with the following files in it:

requirements/
    base.txt
    dev.txt
    prod.txt
    temp.txt

base.txt contains packages to be used in all environments such as Django==1.8.6.

Then dev would include base and other packages, and might look like:

-r base.txt
coverage==4.0.2

Then temp.txt includes dev.txt and contains packages I'm not sure I'll use permanently:

-r dev.txt
temp_package==1.0
git+https://github.com/django/django.git#1014ba026e879e56e0f265a8d9f54e6f39843348

Then I can blow away the entire virtualenv and reinstall it from the appropriate requirements file like so:

pip install -r requirements/dev.txt

Or, to include the temp_package I'm testing:

pip install -r requirements/temp.txt

That's just how I do it, and it helps keep my sandbox separate from the finished product.

like image 59
FlipperPA Avatar answered Nov 28 '25 16:11

FlipperPA



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!