Command "python setup.py egg_info" failed with error code 1 in /tmp/..../

171.8k views Asked by At

I got the following error installing a dependency with pip:

pip9.exceptions.InstallationError Command "python setup.py egg_info" failed with error code 1 in /tmp/tmpoons7qgkbuild/opencv-python/

Below is the result of running the command pipenv install opencv-python on a recent linux (5.4.0 x64) system.

Locking [packages] dependencies…
self.repository.get_dependencies(ireq):
  File "/usr/lib/python3/dist-packages/pipenv/patched/piptools/repositories/pypi.py", line 174, in get_dependencies
    legacy_results = self.get_legacy_dependencies(ireq)
  File "/usr/lib/python3/dist-packages/pipenv/patched/piptools/repositories/pypi.py", line 222, in get_legacy_dependencies
    result = reqset._prepare_file(self.finder, ireq, ignore_requires_python=True)
  File "/usr/lib/python3/dist-packages/pipenv/patched/notpip/req/req_set.py", line 644, in _prepare_file
    abstract_dist.prep_for_dist()
  File "/usr/lib/python3/dist-packages/pipenv/patched/notpip/req/req_set.py", line 134, in prep_for_dist
    self.req_to_install.run_egg_info()
  File "/usr/lib/python3/dist-packages/pipenv/vendor/pip9/req/req_install.py", line 435, in run_egg_info
    call_subprocess(
  File "/usr/lib/python3/dist-packages/pipenv/vendor/pip9/utils/__init__.py", line 705, in call_subprocess
    raise InstallationError(
pip9.exceptions.InstallationError: Command "python setup.py egg_info" failed with error code 1 in /tmp/tmpoons7qgkbuild/opencv-python/
13

There are 13 answers

1
Semnodime On BEST ANSWER

How to fix the pip9.exceptions.InstallationError

Make sure the version of your pip and setuptools is sufficient for manylinux2014 wheels.

A) System Install

sudo python3 -m pip install -U pip
sudo python3 -m pip install -U setuptools

B) Virtual Env / Pipenv

# Within the venv
pip3 install -U pip
pip3 install -U setuptools

Explanation

For me, python setup.py egg_info probably failed because of a recent change in python wheels, as manylinux1 wheels were replaced by manylinux2014 wheels according to open-cv faq.

1
Ertugrul Gacal On

See if the package you are trying to install supports your python version.

I got the same error when trying to install pygame on python3.11.1. Turns out it was because python3.11 is not supported in pygame. Installing pygame on python3.10 worked.

0
Shuai Li On

I hava a same problem.

When I execute:

pip install jupyterlab

it throw an error:

Command "python setup.py egg_info" failed with error code 1 in /private/tmp/pip-build-p0u6Wd/jupyterlab

I try many ways, they all failed.

Finaly, I find there is an anther pip in my computer:

$ pip --version
pip 6.1.1 from /Library/Python/2.7/site-packages (python 2.7)

$ pip3 --version
pip 21.2.4 from /usr/local/lib/python3.9/site-packages/pip (python 3.9)

I use pip3 fix the problem:

pip3 install jupyterlab
0
Alejo L.A On

For me, none of the previous worked. The solution was to force the upgrade of pip since the upgrade was inside of the version and not the current one, e.i, it was something like 9.0.1 but the new one is 21.1.3

python -m pip install --upgrade --force pip

pip3 install --upgrade setuptools

and then retry the installation. I also update wheel along the way.

0
Manoj Parmar On

It requires to upgrade your pip version

pip install --upgrade pip

0
Baker X On

I hava the same problem, when install logging package.and I try the above method, it does work. The log as follow:

env: macos python: 3.11.4

pip3 install logging              
Looking in indexes: https://pypi.xxx
Collecting logging
  Using cached https://pypi.xxx/packages/93/4b/979db9e44be09f71e85c9c8cfc42f258adfb7d93ce01deed2788b2948919/logging-0.4.9.6.tar.gz (96 kB)
  Preparing metadata (setup.py) ... error
  error: subprocess-exited-with-error
  
  × python setup.py egg_info did not run successfully.
  │ exit code: 1
  ╰─> [29 lines of output]
      Traceback (most recent call last):
        File "<string>", line 2, in <module>
        File "<pip-setuptools-caller>", line 14, in <module>
        File "/Users/xxx/Documents/github.com/cloud_test/venv/lib/python3.11/site-packages/setuptools/__init__.py", line 7, in <module>
          import _distutils_hack.override  # noqa: F401
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
        File "/Users/xxx/Documents/github.com/cloud_test/venv/lib/python3.11/site-packages/_distutils_hack/override.py", line 1, in <module>
          __import__('_distutils_hack').do_override()
        File "/Users/xxx/Documents/github.com/cloud_test/venv/lib/python3.11/site-packages/_distutils_hack/__init__.py", line 77, in do_override
          ensure_local_distutils()
        File "/Users/xxx/Documents/github.com/cloud_test/venv/lib/python3.11/site-packages/_distutils_hack/__init__.py", line 63, in ensure_local_distutils
          core = importlib.import_module('distutils.core')
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
        File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/importlib/__init__.py", line 126, in import_module
          return _bootstrap._gcd_import(name[level:], package, level)
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
        File "/Users/xxx/Documents/github.com/cloud_test/venv/lib/python3.11/site-packages/setuptools/_distutils/core.py", line 22, in <module>
          from .dist import Distribution
        File "<frozen importlib._bootstrap>", line 1176, in _find_and_load
        File "<frozen importlib._bootstrap>", line 1147, in _find_and_load_unlocked
        File "<frozen importlib._bootstrap>", line 690, in _load_unlocked
        File "/Users/xxx/Documents/github.com/cloud_test/venv/lib/python3.11/site-packages/_virtualenv.py", line 89, in exec_module
          old(module)
        File "/Users/xxx/Documents/github.com/cloud_test/venv/lib/python3.11/site-packages/setuptools/_distutils/dist.py", line 12, in <module>
          import logging
        File "/private/var/folders/hk/zdx0rgds06s0cpy3wn8kcxj80000gn/T/pip-install-4eajfja1/logging_aed56b05362a4ca9a91698fa2ec8562e/logging/__init__.py", line 618
          raise NotImplementedError, 'emit must be implemented '\
                                   ^
      SyntaxError: invalid syntax
      [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.

 

and then I change the python 3.9.13 ,the problem was solves.

0
questionto42 On

In a project that needs Python2 and pip2, I got the similar error

python setup.py egg_info" failed with error code 1 in /tmp/pip-install-hI6hg8/mpmath/

In the following, "python-pip" is pip2 (python3-pip would be pip3):

apt-get install --upgrade python-pip -y && \
    python -m pip install --upgrade pip

I am not sure whether the second --upgrade is needed, though it does not harm either, the code worked for me.

And then I installed the packages with apt (= apt-get) in as many cases as possible. I checked package by package, example from a Dockerfile:

RUN apt-get install -y python-scipy
RUN apt-get install -y python-sympy
...
RUN python -m pip install opencv-python==3.4.0.12
RUN python -m pip install pyyaml
...

That means: I search for the apt Python2 installer (usually just python-PACKAGENAME, while python3-PACKAGENAME would be for Python3), and if there is none, I take the python -m pip installer (=Python2 as well). After all testing, I put them together in two RUN commands, but that is a side-node for the Dockerfile users.

In any case. Do not use just pip install, since that will call your default pip, and that might fall on a higher version if you have pip3 installed. Even if not, it is clearer to always use python -m pip so that there is no confusion in the future, if pip3 gets installed later.

Without having tested this, the error of the question is perhaps caused by a pip2 that is asked to install a too recent version of "opencv-python". Then you need to limit "opencv-python" to the latest version available in Python2, which is version 3.4.0.12:

python -m pip install opencv-python==3.4.0.12
1
Jesus Campon On

I just ran into a similar problem when trying to install the Google Cloud Platform package for BigQuery on Python 3.6 which was throwing me the following error: (couldn't copy and paste before I lost it, so this is a approximation of the exact error I got)

[...]InstallationError: Command "python setup.py egg_info" failed with error code 1 in /tmp/<some_folder>/grpcio/

And after following other threads with the most recommended options to upgrade the setuptools, not using the cached packages, using the local user option, etc... Nothing worked

python3 -m pip install --user --no-cache-dir google-cloud-bigquery
python3 -m pip install --upgrade setuptools

Then, when looking a bit more carefully into the actual error message, I could see that the failing line was also referring to what I thought may be another dependency package: grpcio

So sure enought, I thought about trying also to upgrade or re-install that grpcio package and see what would happen.

I tried first with just upgrading that package:

python3 -m pip install --no-cache-dir --user --upgrade grpcio

And it did upgrade fine. So next I tried to upgrade the google-cloud-bigquery package again, and this time around it also worked perfectly and that solved the problem!

So basically it seems that ensuring the whole dependency chain is available and installed properly may do the trick as well, which makes total sense when you think about it

I hope this helps some people.

1
DvdG On

I solved a similar issue following this link https://www.edureka.co/community/69396/command-python-setup-info-failed-error-build-8nhf9w2t-grpcio and using the following command:

$ pip3 install --upgrade setuptools
$ pip3 install --upgrade pip
2
veben On

For python 3.7, I have to execute the following commands to update pip and setuptools dependencies:

sudo python3.7 -m pip install -U pip
sudo python3.7 -m pip install -U setuptools

For python 2.7, I have to update pip and setuptools dependencies AND have to install python-dev & libpq-dev packages:

sudo python2.7 -m pip install -U pip
sudo python2.7 -m pip install -U setuptools
sudo apt-get install python-dev libpq-dev
0
kmt On

Sometimes this error can be raised as the result of another error occurring, so if upgrading doesn't work for you it might be worth rerunning pipenv with the --verbose option. E.g. in my case it turned out there was a problem with the scikit-image install but I could only see the error when running --verbose:

 ...
 scikit-image==0.19.1 not in cache, need to check index

INFO:pip9._vendor.requests.packages.urllib3.connectionpool:Starting new HTTPS connection (1): pypi.org
INFO:notpip.req.req_set:Collecting scikit-image==0.19.1
INFO:pip9.download:Using cached https://files.pythonhosted.org/packages/e7/54/4b57761f25be6e2536130ca3bc8742dee45bb9047c5df798197203220e37/scikit-image-0.19.1.tar.gz
INFO:pip9.download:Saved /blah/.cache/pipenv/pkgs/scikit-image-0.19.1.tar.gz
INFO:pip9.utils:Complete output from command python setup.py egg_info:
INFO:pip9.utils:Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "/tmp/tmpszjqw2gobuild/scikit-image/setup.py", line 20, in <module>
    from pythran.dist import PythranBuildExt as pythran_build_ext
ModuleNotFoundError: No module named 'pythran'

----------------------------------------
Traceback (most recent call last):
  File "/usr/lib/python3/dist-packages/pipenv/resolver.py", line 82, in <module>
    main()
  File "/usr/lib/python3/dist-packages/pipenv/resolver.py", line 71, in main
    clear=do_clear,
  File "/usr/lib/python3/dist-packages/pipenv/resolver.py", line 63, in resolve
    verbose=verbose,
  File "/usr/lib/python3/dist-packages/pipenv/utils.py", line 425, in resolve_deps
    pre,
  File "/usr/lib/python3/dist-packages/pipenv/utils.py", line 336, in actually_resolve_reps
    resolved_tree.update(resolver.resolve(max_rounds=PIPENV_MAX_ROUNDS))
  File "/usr/lib/python3/dist-packages/pipenv/patched/piptools/resolver.py", line 102, in resolve
    has_changed, best_matches = self._resolve_one_round()
  File "/usr/lib/python3/dist-packages/pipenv/patched/piptools/resolver.py", line 200, in _resolve_one_round
    for dep in self._iter_dependencies(best_match):
  File "/usr/lib/python3/dist-packages/pipenv/patched/piptools/resolver.py", line 297, in _iter_dependencies
    dependencies = self.repository.get_dependencies(ireq)
  File "/usr/lib/python3/dist-packages/pipenv/patched/piptools/repositories/pypi.py", line 174, in get_dependencies
    legacy_results = self.get_legacy_dependencies(ireq)
  File "/usr/lib/python3/dist-packages/pipenv/patched/piptools/repositories/pypi.py", line 222, in get_legacy_dependencies
    result = reqset._prepare_file(self.finder, ireq, ignore_requires_python=True)
  File "/usr/lib/python3/dist-packages/pipenv/patched/notpip/req/req_set.py", line 644, in _prepare_file
    abstract_dist.prep_for_dist()
  File "/usr/lib/python3/dist-packages/pipenv/patched/notpip/req/req_set.py", line 134, in prep_for_dist
    self.req_to_install.run_egg_info()
  File "/usr/lib/python3/dist-packages/pipenv/vendor/pip9/req/req_install.py", line 439, in run_egg_info
    command_desc='python setup.py egg_info')
  File "/usr/lib/python3/dist-packages/pipenv/vendor/pip9/utils/__init__.py", line 707, in call_subprocess
    % (command_desc, proc.returncode, cwd))
pip9.exceptions.InstallationError: Command "python setup.py egg_info" failed with error code 1 in /tmp/tmpszjqw2gobuild/scikit-image/
1
yoga333 On

You need to upgrade to pip9.0.3 first, and then upgrade to the latest version. The command is:

pip install pip==9.0.3
pip install --upgrade pip
1
ACE9 On

None of the other solutions worked for me as a last resort i tried reinstalling pipenv using the command: conda install -c conda-forge pipenv