Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

tell pip to install the dependencies of packages listed in a requirement file

Developing a Django web app, I have a list of packages I need to install in a virtualenv. Say:

Django==1.3.1 --extra-index-url=http://dist.pinaxproject.com/dev/ Pinax==0.9b1.dev10 git+git://github.com/pinax/pinax-theme-bootstrap.git@cff4f5bbe9f87f0c67ee9ada9aa8ae82978f9890 # and other packages 

Initially I installed them manually, one by one, along the development. This installed the required dependencies and I finally used pip freeze before deploying the app.

Problem is, as I upgraded some packages, some dependencies are no longer used nor required but they keep being listed by pip freeze.

Now, I'd like to set up a new virtualenv this way:

  • put the needed packages (without their dependencies) in a requirement file,
    like manual-requirements.txt
  • install them with their dependencies
    pip install -r manual-requirement.txt (← problem, this does not install the dependencies)
  • freeze the full virtualenv
    pip freeze -r manual-requirements.txt > full-requirements.txt
    and deploy.

Any way to do this without manually re-installing the packages in a new virtualenv to get their dependencies ? This would be error-prone and I'd like to automate the process of cleaning the virtualenv from no-longer-needed old dependencies.

edit: actually, pip does install dependencies not explicitly listed in the requirement file, even if the documentation tells us that such files are flat. I was wrong about which dependencies i expected to be installed. I'll let this question for anyone in doubt about pip not installing all dependencies.

like image 277
Maxime R. Avatar asked Apr 26 '12 12:04

Maxime R.


People also ask

When you use pip to install a package that requires one or more dependencies?

Pip relies on package authors to stipulate the dependencies for their code in order to successfully download and install the package plus all required dependencies from the Python Package Index (PyPI). But if packages are installed one at a time, it may lead to dependency conflicts.

How do I get-pip dependency package?

In this case, you have two options: Use the pipdeptree utility to gather a list of all dependencies, create a requirements. txt file listing all the dependencies, and then download them with the pip download command. Get the list of dependencies for a package from the setup.py file.


1 Answers

Simply use:

pip install -r requirements.txt 

This installs all dependencies listed in requirements.txt file.

like image 125
Ming Avatar answered Sep 23 '22 01:09

Ming