home ¦ Archives ¦ Atom ¦ RSS

TIL pip requirements

Python logo Today I Learned about pip requirement files. pip is a package installation tool for Python. It’s great when you combine it with virtualenv, so that you can easily build up complex Python installations with clean isolation from your base installation.

The kicker is pip freeze > req_file.txt and pip -r req_file.txt which will stash your installed packages and load them into a new environment. Makes it easy to kit out a new virtual environment with your favorite 3rd party modules. You only have to figure out the complete list of stuff you want once and then install it with one command line. And of course you can keep around variations of req_file.txt for different install types.

Bonus: You can use virtualenvwrapper post install hooks to automatically run pip on a newly created virtual environment. You are using virtualenvwrapper aren’t you?

© C. Ross Jam. Built using Pelican. Theme by Giulio Fidente on github.