Search code examples
pythonpippackagesetuptools

Installing packages on computer in a closed network


I am not able to install some packages with pip on a computer that has no access to internet. I have a clean install of python3.10 from source file. Here is the command I run:

pip3.10 install --no-index --find-links=/path/to/my/local/python-libs --no-cache-dir virtualenv

In the directory /path/to/my/local/python-libs, I put zip files of package releases:

  • setuptools-62.1.0.zip
  • virtualenv-20.8.1.zip
  • wheel-0.37.1.zip

I have tried the options --use-deprecated=legacy-resolver but it does not work too. The error message is:

  Processing ./python-libs/setuptools-62.1.0.zip
    Getting requirements to build wheel: started
    Getting requirements to build wheel: finished with status 'done'
    Installing backend dependencies: started
    Installing backend dependencies: finished with status 'done'
    Preparing metadata (pyproject.toml): started
    Preparing metadata (pyproject.toml): finished with status 'done'
  Discarding file:///home/user/python-libs/setuptools-62.1.0.zip: Requested setuptools>=41.0.0 from ile:///home/user/python-libs/setuptools-62.1.0.zip has inconsistent version: filename has '62.1.0', but metadata has '62.1.0.post20220423'
  ERROR: Could not find a version that satisfies the requirement setuptools>=41.0.0 (from versions: 62.1.0)
  ERROR: No matching distribution found for setuptools>=41.0.0

I have spent a whole day looking for the causes, maybe it is caused by the new pip resolver or the PEP517, no idea.


Solution

  • I think if you want to install python moldules without internet, since you have them downloaded already, is to first make a requirements.txt file with the following.

    setuptools==62.1.0
    virtualenv==20.8.1
    wheel==0.37.1
    

    I just took the version number from your download files

    Then go to the dir that have the requirements.txt run

    pip install -r requirements.txt --no-index --find-links --find-links=/path/to/my/local/python-libs
    

    note adding the -r requirements.txt allows you to control the version number of the pip packages.

    If this doesn't solve the problem then it might be something wrong with your downloaded binaries, try downloading them again but this time use the requirements.txt

    pip download -r requirements.txt -d binaries
    

    This will download the binaries and the versions requested from the requirements.txt into a folder called binaries

    Then just try the first command again on your offline machine once you moved the new binaries to the required folder (/path/to/my/local/python-libs) .