Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

PIP: Installing only the dependencies

I have a script that creates a virtualenv, installs distribute and pip in it and then optionally clones a git repo.

Now I have the project I will be working on, installed. But its dependencies are not installed. How can I make pip install all the dependencies as if I have issued a pip install MyApp?

EDIT: Appareantly my question is a duplicate of this one.

Not exactly sure but pip install -e . seems to do what I want without too many extra stuff lying around. I'd prefer if my code wasn't linked from site-packages though.

like image 543
muhuk Avatar asked Feb 23 '10 10:02

muhuk


People also ask

Does pip install all 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).

How do I resolve dependencies in pip?

Unfortunately, pip makes no attempt to resolve dependency conflicts. For example, if you install two packages, package A may require a different version of a dependency than package B requires. Pip can install from either Source Distributions (sdist) or Wheel (. whl) files.

How do you install dependencies in Python?

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

If your dependencies are defined in the setup.py file, you can first dump them to an external file using:

python setup.py egg_info 

This will list all your dependencies in YOUR_PROJECT.egg-info/requires.txt file. Then you can install them using pip:

pip install -r *.egg-info/requires.txt 
like image 168
Jakub Kukul Avatar answered Oct 05 '22 23:10

Jakub Kukul