altern
altern

Reputation: 5949

Offline installation for pip packages fails with error "Could not find a version that satisfies the requirement"

In order to make packages installed offline, I use the -d (or --download) option to pip install. For instance, pip install --download dependencies -r requirements.txt will download the packages for all required dependencies mentioned in requirements.txt to dependencies dir (but will not install them). Then I use pip install --no-index --find-links dependencies -r requirements.txt to install those downloaded packages without accessing the network.

Most of the time it works fine, but sometimes installation fails with error "Could not find a version that satisfies the requirement xyz". After doing pip install --user xyz --find-links dependencies manually (xyz IS present in the dependencies folder), installation fails with the same "Could not find a version that satisfies the requirement abc" error, but with different package 'abc'. It repeats several times until I manually resolve all failed dependencies.

How could I make run pip install --no-index --find-links dependencies -r requirements.txt without those weird dependency errors not finding packages that are already there?

Upvotes: 2

Views: 3491

Answers (1)

NBajanca
NBajanca

Reputation: 3730

Make sure of two things:

  1. The pip version is the same in the offline server and in the online one.

    • To find out: pip -V
    • To update (if needed): pip install --upgrade pip
  2. The python version is the same in both virtual enviroments or servers.

    • To find out: python (the header will have the version info)

In my case I was calling pip install --download outside the virtual environment (using default python version - 2.7) and then installing in a virtual environment with python 3 and the error I got was exactly the one you mentioned.

Upvotes: 1

Related Questions