Search code examples
pythonlinuxbashpippackage

setuptools not available - error when installing Python package with pip


I'm trying to install the importlib package using pip3, but I'm getting an error that says "Can not execute setup.py since setuptools is not available in the build environment." How can I fix this error and successfully install the importlib package?

mrichardsonr1@penguin:~$ pip3 install importlib
Defaulting to user installation because normal site-packages is not writeable
Collecting importlib
  Using cached importlib-1.0.4.zip (7.1 kB)
  Preparing metadata (setup.py) ... error
  error: subprocess-exited-with-error
  
  × python setup.py egg_info did not run successfully.
  │ exit code: 1
  ╰─> [1 lines of output]
      ERROR: Can not execute `setup.py` since setuptools is not available in the build environment.
      [end of output]
  
  note: This error originates from a subprocess, and is likely not a problem with pip.
error: metadata-generation-failed

× Encountered error while generating package metadata.
╰─> See above for output.

note: This is an issue with the package mentioned above, not pip.
hint: See above for details.

I have uninstalled pip, setuptools, updated everything reinstalled everything, nothing works. I am running this on Linux x86_64 container on ChromeOS. I am using the latest version of setuptools which is what I was told could be causing this.

mrichardsonr1@penguin:~$ pip3 install setuptools
Defaulting to user installation because normal site-packages is not writeable
Requirement already satisfied: setuptools in ./.local/lib/python3.9/site-packages (65.6.3)

As far as I know everything else is up to date. No clue why I am getting this error, and it's not just when installing this package I had the same issue trying to install the ping package.


Solution

  • https://pypi.org/project/importlib/

    Installation package importlib is only for Python 2.7, you cannot install it with pip3.

    In Python 3 importlib became a package from the standard library: https://docs.python.org/3/library/importlib.html . You don't need to install it separately; once you've installed Python3 and the standard library the package is available for import. To check from the command line:

    $ python3 -c "import importlib"