简体   繁体   中英

Python pip installer not controlling versions of packages

I ran into a version control issue regarding pip (Python 2.7.14). I updated pip to version 20.3.3. And then installed python packages. I specified the versions for each package. The issue arose when installing sympy, version 1.3 (command line code shown below):

C:\Python27\python.exe C:\Python27\Scripts\pip.exe install --no-cache-dir sympy==1.3

sympy installs mpmath, version 0.19, as a dependency. pip proceeds to say it is downloading mpmath version 0.19, but then attempts to install version 1.2.1. pip then returns an error, stating that the install has failed. The issue can be worked around by first installing mpmath directly, version 0.19, and then proceeding to install sympy, version 1.3. Since the mpmath dependency is already satisfied, sympy skips trying to download and install mpmath. sympy is then able to install successfully.

Is there a way to control the version of dependencies when pip installs them from other packages? I would like to be able to control all versions to ensure my software produces the same results over time.

I suggest you to try pip-tools : https://github.com/jazzband/pip-tools

All you have to do is writing a requirements.in file where you can pin the first level dependencies ( sympy in your case).

You then run pip-compile requirements.in : a requirements.txt will be generated automatically with all the dependencies pinned as well.

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