Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

In Python, `pip -r requirements.txt` doesn't install packages *recursively*?

Tags:

I'm using Python 3.5.1 and pip 7.1.2:

pip3 --version
pip 7.1.2 from /Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages (python 3.5)

In my requirements.txt, I write:

pysam>=0.9.0

Then I use pip3 to install this requirements.txt file like this:

pip3 install -U -r requirements.txt

This pysam has its own dependencies: cython, which can be seen at: https://github.com/pysam-developers/pysam/blob/master/requirements.txt

However, using pip3 install -U -r requirements.txt seems not to install pysam's dependency recursively, it will throw an expection that ValueError: no cython installed.

Does anyone have ideas about why requirements.txt are not installed recursively?

like image 594
Hanfei Sun Avatar asked May 06 '16 02:05

Hanfei Sun


1 Answers

The pysam setup.py script seems to use requires instead of the typical install_requires; the latter generates the metadata that pip needs to figure out its requirements. In fact, pysam seems to need cython in order to build itself, so more appropriately, it should be using setup_requires. You can check that installing pysam fails the normal way if you don't have cython installed.

(edit: DOES NOT WORK) In any case, you can get around this by placing cython before pysam in your requirements file; that way, pip will try to install cython before it moves on the pysam:

cython>=0.22
pysam>=0.9.0

Edit: to be clear, this has nothing to do with pip -r requirements.txt itself. It's that pip doesn't receive enough metadata from pysam to know that it needs to install cython first before trying to install pysam.

Second edit: You're right. The installation still fails because pip tries to get the metadata from the pysam setup script before it moves on to the build stage, and the pysam setup script throws that error if cython isn't installed. In this specific case, I'm not sure there's a solution beyond installing Cython in a seperate command, beforehand.

like image 69
Te-jé Rodgers Avatar answered Sep 28 '22 04:09

Te-jé Rodgers