8

I am seriously stumped with this one and can't find any questions that match.

If I run pip3 show setuptools or pip2 list, both say that setuptools 40.8.0 is installed, but when I try to install a module locally, from a local source code directory, I get the error that says No matching distribution found for setuptools>=40.8.0

Due to access and firewall restrictions, I have to install the module into my home directory and using what's already installed on the system.

This worked with the previous version of the module, but now it's failing.

RayInNoIL
  • 817
  • 10
  • 18
  • 1
    "*…when I try to install a module locally, from a local source code directory…*" What command did you run? Please show the text of the command and the entire text of the error message (traceback). Even if you have `setuptools` 40.8.0 installed a package that explicitly declared `setuptools` as a dependency requires `setuptools` distribution to exist in the local directory. – phd Feb 21 '23 at 10:32
  • 1
    To install packages on an offline host you need to download all dependencies recursively (see https://stackoverflow.com/a/14447068/7976758), move them to the offline host and install. See https://stackoverflow.com/search?q=%5Bpip%5D+offline – phd Feb 21 '23 at 10:34
  • @phd: I'll have to see if something changed between the first version installed and the current version. I'm running the same commands that worked with the earlier version. I'll re-type the command, I can't copy/paste to/from the system. --- That said, setuptools 40.8.0 is installed in ```site-packages``` under ```…/python/lib```. Do I actually need to install the packages under ```$HOME```, even if they're under the main Python install? – RayInNoIL Feb 21 '23 at 15:23
  • 1
    I had similar issues when installing a pip package like this: ``pip3 install setuptools torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cu118`` Setuptools is there in the lib of the venv, but the torch install can't find it. Was not able to work out why. – user1603472 Jul 12 '23 at 09:33
  • 2
    @user1603472 I fixed it by running `pip install lit` or whichever library failed right before the setuptools error. – Sylvain Jul 19 '23 at 14:01

1 Answers1

1

I had this problem trying to build psycopg from source, using downloaded dependencies on an air-gapped machine.

I did this initially :

$ python3.11 -m venv tmp-venv
$ . tmp-venv/bin/activate
$ pip list
Package    Version
---------- -------
pip        22.3.1
setuptools 65.5.0
$ mkdir deps
$ pip download --destination-dir=deps wheel tomli==2.0.1 backports.zoneinfo==0.2.1 typing_extensions==4.7.1 psycopg==3.1.9 psycopg-c==3.1.9
$ pip install --no-index --find-links=deps wheel tomli

I then executed

$ pip install --no-index --find-links=deps psycopg[c]

which errored out with

  × pip subprocess to install build dependencies did not run successfully.
  │ exit code: 1
  ╰─> [3 lines of output]
      Looking in links: deps
      ERROR: Could not find a version that satisfies the requirement setuptools>=49.2.0 (from versions: none)
      ERROR: No matching distribution found for setuptools>=49.2.0
      [end of output]

The solution, gleaned from this GitHub issue, was to add the --no-build-isolation flag so that pip would find the setuptools installation.

pip install --no-index --find-links=deps --no-build-isolation psycopg[c]

Build isolation is a feature of PEP518 in which the build process does not look for build-time dependencies (such as setuptools) in the local environment. The --no-build-isolation flag disables this feature so that the local setuptools installation is used for the build.

snakecharmerb
  • 47,570
  • 11
  • 100
  • 153