Search code examples
pythonpipfreezepypi

pip can't find required versions


I recently finished a project working in a fresh conda environment. During development I downloaded packages as required. I created a requirements.txt file using pip freeze > requirements.txt. Now I'm trying to reproduce that environment on a web server. This web server automatically calls pip install -r requirements.txt to download the required packages. However this process fails on many of the dependencies with

ERROR: Could not find a version that satisfies the requirement ...

From what I can tell the version numbers listed in the requirements.txt file are much higher than those on PyPI.

As an example, the requirements.txt file calls for mkl-fft==1.0.15 (optimizations to NumPy) but PyPI only lists up to version 1.0.6. The mkl-fft github has up to version 1.1.

I think this is the discrepancy causing the "Could not find a version that satisfies..." error. Can anyone confirm?

I can remove the version number and pip will download the latest version it can find, but I have 5-6 packages like this. Given that other packages are expecting these versions (e.g. numpy works with mkl-fft) mismatching the versions results in runtime failures in the replicated environment.

Is there a fix to help pip install get the specified versions?


Solution

  • Indeed, it seems that (some) packages provided by conda have hight version numbers than the ones available from pypi. For example, with mkl-fft:

    • pypi has version 1.0.6
    • Conda has version 1.1.0

    If you created your dev environment using conda, you should probably based your prod environment on conda as well - using conda list --export to create the requirements, and conda create --name <envname> --file requirements.txt to replicate the environment.