How to specify install order for python pip?

后端 未结 9 1454
[愿得一人]
[愿得一人] 2020-11-30 02:22

I\'m working with fabric(0.9.4)+pip(0.8.2) and I need to install some python modules for multiple servers. All servers have old version of setuptools (0.6c8) which needs to

相关标签:
9条回答
  • 2020-11-30 02:37

    Sadly the upgrade suggestion won't work. If you read the other details in https://github.com/pypa/pip/issues/24 you will see why

    pip will build all packages first, before attempting to install them. So with a requirements file like the following

    numpy==1.7.1
    scipy==0.13.2
    statsmodels==0.5.0
    

    The build of statsmodels will fail with the following statement

    ImportError: statsmodels requires numpy
    

    The workaround given for manually calling pip for each entry in the requirements file (via a shell script) seems to be the only current solution.

    0 讨论(0)
  • 2020-11-30 02:47

    Sorry, my first answer was wrong, because I had setuptools>=0.6c9.

    It seems it is not possible because pymongo's setup.py needs setuptools>=0.6c9, but pip has only downloaded setuptools>=0.6c9, and not installed yet.

    Someone discussed about it in the issue I pointed before.

    I have my own created an issue some weeks ago about it: Do not run egg_info to each package in requirements list before installing the previous packages.

    Sorry for the noisy.


    First answer:

    Upgrade your pip to 0.8.3 version, it has a bugfix to installation order.

    Now if you upgrade everything works :-)

    Check the news here: http://www.pip-installer.org/en/0.8.3/news.html

    0 讨论(0)
  • 2020-11-30 02:52

    You can just use:

    cat requirements.txt | xargs pip install
    
    0 讨论(0)
  • 2020-11-30 02:52

    Following on from @lukasrms's solution - I had to do this to get pip to install my requirements one-at-a-time:

    cat requirements.txt | xargs -n 1 pip install
    
    0 讨论(0)
  • 2020-11-30 02:53

    If you have comments in your requirements file you'll want to use:

    grep -v "^#" requirements.txt | xargs pip install
    
    0 讨论(0)
  • 2020-11-30 02:54

    Pymongo requires setuptools>=0.6c9

    How do you know? Requires to build or to install? You don't say what version of Pymongo you were trying to install but looking at setup.py file for current (3.2.2) version there's no specification of neither what Pymongo requires to run setup.py (setup_requires) nor what it requires to install (install_requires). With no such information pip can't ensure specific version of setuptools. If Pymongo requires specific version of setuptools to run its setup.py (as opposed to requiring setuptools to run setup function itself) then the other problem is that until recently there was no way to specify this. Now there's specification – PEP 518 – Specifying Minimum Build System Requirements for Python Projects, which should be shortly implemented in pip – Implement PEP 518 support #3691.

    As to order of installation, this was fixed in pip 6.1.0;

    From pip install – Installation Order section of pip's documentation:

    As of v6.1.0, pip installs dependencies before their dependents, i.e. in "topological order". This is the only commitment pip currently makes related to order.

    And later:

    Prior to v6.1.0, pip made no commitments about install order.

    However, without proper specification of requirements by Pymongo it won't help either.

    0 讨论(0)
提交回复
热议问题