I'm trying to install a requirements.txt file in Docker, and I make it about 30 packages in when I get this error when trying to install importlib:
Can not execute setup.py
since setuptools is not available in the build environment.
Here is the full error message:
Collecting importlib==1.0.4
#9 14.42 Downloading importlib-1.0.4.zip (7.1 kB)
#9 14.43 Preparing metadata (setup.py): started
#9 14.45 Preparing metadata (setup.py): finished with status 'error'
#9 14.45 error: subprocess-exited-with-error
#9 14.45
#9 14.45 × python setup.py egg_info did not run successfully.
#9 14.45 │ exit code: 1
#9 14.45 ╰─> [1 lines of output]
#9 14.45 ERROR: Can not execute `setup.py` since setuptools is not available in the build environment.
#9 14.45 [end of output]
#9 14.45
#9 14.45 note: This error originates from a subprocess, and is likely not a problem with pip.
#9 14.45 error: metadata-generation-failed
#9 14.45
#9 14.45 × Encountered error while generating package metadata.
#9 14.45 ╰─> See above for output.
#9 14.45
#9 14.45 note: This is an issue with the package mentioned above, not pip.
#9 14.45 hint: See above for details.
In the Dockerfile, I have tried installing setuptools before installing the packages:
RUN python3 -m pip install setuptools
RUN python3 -m pip install -r requirements.txt
Some further details: my python version is 3.9, pip version is 22.1.2
When I do
easy_install --version
, I get
setuptools 41.0.1 from /System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python (Python 2.7)
However, when I try to install setuptools with pip, it says I have version 62.3.3 for python3.9
Requirement already satisfied: setuptools in /Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages (62.3.3)
Any help is greatly appreciated, and let me know if I should provide any further details.
importlib
?importlib
is part of Python's standard library, so it should always be available without needing to install it from PyPI with pip. -- To be accurate there is animportlib
on PyPI but it is meant only for very old versions of Python that do not haveimportlib
out of the box. – Philomena