Using pipdeptree in a virtualenv

Each of our Django projects at the CTL has a requirements.txt, which we use to download dependencies with pip using the --no-deps flag. We need to explicitly list each dependency in requirements.txt, otherwise we run into runtime errors.

Like piprot, pipdeptree is a nice pip utility for getting some info around the requirements.txt file. Unlike piprot, it's not as simple to use. You can't do something like piprot -o requirements.txt, where the piprot I'm referring to here may or may not be in the same virtualenv as the Django project.

pipdeptree needs to be installed in the same virtualenv, and needs to be called in a slightly different way, so I thought it was worth documenting here.

$ virtualenv ve
$ ./ve/bin/pip install -r requirements.txt
$ ./ve/bin/pip install pipdeptree
$ ./ve/bin/python -m pipdeptree
  - setuptools
  - ipython [required: >=0.10, installed: 4.1.1]
    - traitlets [installed: 4.0.0]