简体   繁体   中英

pip complains about dependency versions but installs them anyway. Why?

I have a requirements file defined like this:

requirements.txt

botocore==1.15.11
docutils==0.16

When I hit pip install -r requirements.txt I see this error:

botocore 1.15.11 has requirement docutils<0.16,>=0.10, but you'll have docutils 0.16 which is incompatible.

However, when I hit pip list I see this as the output:

botocore        1.15.11
docutils        0.16   
jmespath        0.10.0 
pip             18.1   
python-dateutil 2.8.1  
setuptools      40.6.2 
six             1.15.0 
urllib3         1.25.9 
wheel           0.34.2 

This indicates that the two dependencies were installed as per definition in the requirements.txt file. Why is complaining about it if it's not a problem? If it is a problem, how did they get installed?

There are some well-known issues (limitations and bugs) with pip 's current dependency solver. A new (better) one is in progress. It can already be tested. More details in this answer and its links: https://stackoverflow.com/a/60926641/11138259

With that said, these two requirements are incompatible:

  • botocore==1.15.11
  • docutils==0.16

As can be seen in the setup.cfg for botocore 1.15.11 :

[bdist_wheel]
universal = 1

[metadata]
requires-dist =
    python-dateutil>=2.1,<3.0.0
    jmespath>=0.7.1,<1.0.0
    docutils>=0.10,<0.16
    urllib3>=1.20,<1.25.8; python_version=='3.4'
    urllib3>=1.20,<1.26; python_version!='3.4'

It's still possible to instruct pip to install such a combination (one that is advertised as not compatible) anyway. And pip will warn about this conflict, as you showed in your question, or by running pip check (which by the way, as far as I know, as of today, uses the newer dependency resolution already):

$ pip check
botocore 1.15.11 has requirement docutils<0.16,>=0.10, but you have docutils 0.16.

The imports and the executed code might still work without any (apparent) issue though. For example: it could be that botocore 1.15.11 is not actually entirely incompatible with docutils 0.16 . Either the code path that would trigger an issue is not hit, or the restriction docutils<0.16 was just made as a preventive measure.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM