ERROR: Command errored out with exit status 1: python setup.py egg_info

avatar
Borislav Hadzhiev

6 min

banner

# ERROR: Command errored out with exit status 1: python setup.py egg_info

To solve the "ERROR: Command errored out with exit status 1: python setup.py egg_info":

  1. Upgrade your versions of pip , setuptools and wheel before running pip install .
  2. On Windows, download and install the package from unofficial binaries.
  3. Try to install the package with the --pre option.
  4. Check if your Python version is supported by the package.
shell
ERROR: Command errored out with exit status 1: File "c:\users\bobbyhadz\appdata\local\programs\python\python310\lib\site-packages\setuptools\msvc.py", line 371, in _find_latest_available_vc_ver raise distutils.errors.DistutilsPlatformError(err) distutils.errors.DistutilsPlatformError: Microsoft Visual C++ 14.0 is required. Get it with "Microsoft Visual C++ Build Tools": https://visualstudio.microsoft.com/downloads/ ---------------------------------------- ERROR: Command errored out with exit status 1: python setup.py egg_info Check the logs for full command output.

# Upgrade your version of pip

The first thing you should do is try to upgrade your versions of pip , setuptools and wheel before installing the module.

Here are the commands for upgrading pip on all operating systems.

Which command works depends on your operating system and your version of Python.

shell
# 👇️ if you have pip already installed pip install --upgrade pip # 👇️ if your pip is aliased as pip3 (Python 3) pip3 install --upgrade pip # 👇️ if you don't have pip in your PATH environment variable python -m pip install --upgrade pip python3 -m pip install --upgrade pip py -m pip install --upgrade pip # 👇️ if you have easy_install easy_install --upgrade pip # 👇️ if you get a permissions error sudo easy_install --upgrade pip # 👇️ if you get a permissions error when upgrading pip pip install --upgrade pip --user # 👇️ upgrade pip scoped to the current user (if you get permissions error) python -m pip install --user --upgrade pip python3 -m pip install --user --upgrade pip # 👇️ Installing directly from get-pip.py (MacOS and Linux) curl https://bootstrap.pypa.io/get-pip.py | python # 👇️ if you get permissions issues curl https://bootstrap.pypa.io/get-pip.py | sudo python # 👇️ alternative for Ubuntu/Debian sudo apt-get update && apt-get upgrade python-pip # 👇️ alternative for Red Hat / CentOS / Fedora sudo yum install epel-release sudo yum install python-pip sudo yum update python-pip

Now that your version of pip is updated, update the setuptools and wheel packages as well.

shell
pip install --upgrade setuptools wheel pip3 install --upgrade setuptools wheel python -m pip install --upgrade setuptools wheel python3 -m pip install --upgrade setuptools wheel py -m pip install --upgrade setuptools wheel

Try to run the pip install command after updating setuptools and wheel .

shell
pip install numpy pip3 install numpy python -m pip install numpy python3 -m pip install numpy py -m pip install numpy

Make sure to replace numpy with the name of the module you're trying to install.

# Run the pip install command with the --upgrade flag

If the error is not resolved, try to run the pip install command with the --upgrade option to install the latest version of the module.

shell
pip install numpy --upgrade pip3 install numpy --upgrade python -m pip install numpy --upgrade python3 -m pip install numpy --upgrade

The --upgrade option upgrades the specified package to the newest available version.

If the command works, make sure to update your requirements.txt file if you have one.

shell
pip freeze > requirements.txt

# Disable the cache when running the command

You can also try to disable the cache with the --no-cache-dir option.

shell
pip install numpy --no-cache-dir pip3 install numpy --no-cache-dir python -m pip install numpy --no-cache-dir python3 -m pip install numpy --no-cache-dir

If the error persists, use the --pre option to include pre-release and development versions of the package.

shell
pip install numpy --pre pip3 install numpy --pre python -m pip install numpy --pre python3 -m pip install numpy --pre

The --pre option makes it so pip includes pre-release and development versions of the package. By default pip only finds stable versions.

This sometimes helps because a pre-release version of the package might have a wheel available for your version of Python.

If the command works, make sure to update your requirements.txt file if you have one.

shell
pip freeze > requirements.txt

If the error is not resolved, try running the pip install command with the --no-use-pep517 option.

shell
pip install --no-use-pep517 numpy pip3 install --no-use-pep517 numpy python -m pip install --no-use-pep517 numpy python3 -m pip install --no-use-pep517 numpy

If you are on Windows, download a suitable .whl file for the package and install it.

If you aren't on Windows, scroll past the next subheading.

# Download and install a .whl file if you are on Windows

If you are on Windows, you can also download a suitable .whl file from the https://www.lfd.uci.edu/~gohlke/pythonlibs/ website.

First, get your Python version and check if your Python installation is 64-bit or 32-bit .

You can do that by opening CMD and typing python .

get python version and bits

For example, the screenshot shows that my Python version is 3.10 and my Python interpreter is 64-bit.

Now, click on the https://www.lfd.uci.edu/~gohlke/pythonlibs/ link, press CTRL + f and search for the name of the package.

Download the corresponding .whl file. For example, if I were trying to install the gensim package, I would download the following file.

shell
gensim‑4.2.0‑cp310‑cp310‑win_amd64.whl
The cp310 part is the version (Python 3.10) and amd64 means 64-bit.

Once you open the file, open your shell in the directory where the file is located (e.g. C:\Users\Example\Downloads ) and install it using pip :

  1. Open the directory that contains the file in Explorer.
  2. Press Shift and right-click in Explorer.

windows open powershell window here

  1. Click on "Open PowerShell window here" .
  2. Run the following command.
shell
pip install gensim‑4.2.0‑cp310‑cp310‑win_amd64.whl pip3 install gensim‑4.2.0‑cp310‑cp310‑win_amd64.whl
Make sure to specify the name of the .whl file correctly as your Python version and the name of the package will likely be different.

If that didn't help and your error message contains something like: "error: Microsoft Visual C++ 14.0 or greater is required. Get it with "Microsoft C++ Build Tools": https://visualstudio.microsoft.com/visual-cpp-build-tools/ " , download Microsoft Build tools and check the "Desktop development with C++ checkbox when installing.

install microsoft build tools

# Check if your Python version is supported by the package

The error is sometimes caused when the package you are trying to install doesn't have available wheels for your version of Python.

You can check your Python version with the python --version command.

shell
python --version

get python version

You can check if a package has wheels available for a specific Python version in the Download files section of the package's pypi page.

For example, cp310 in the name of a file under "Built Distributions" means Python version 3.10 is supported for the specific operating system.

If the .whl files are not available for your version of Python, you can download an older version.

You can download a specific Python version that is supported by the package if the package doesn't support the latest Python version.

Different versions are available in the "Looking for a specific release" table .

install specific python version

Make sure to tick the following options if you get prompted:

  • Install launcher for all users (recommended)
  • Add Python to PATH (this adds Python to your PATH environment variable)

# Create a virtual environment

To solve the error:

  1. Create a virtual environment.
  2. Activate the virtual environment.
  3. Run the pip install command with the virtual environment active.
shell
# 👇️ use correct version of Python when creating VENV python -m venv venv # 👇️ activate on Unix or MacOS source venv/bin/activate # 👇️ activate on Windows (cmd.exe) venv\Scripts\activate.bat # 👇️ activate on Windows (PowerShell) venv\Scripts\Activate.ps1 # 👇️ install the specific package in the virtual environment pip install tensorflow

If the python -m venv venv command doesn't work, try the following 2 commands:

  • python3 -m venv venv
  • py -m venv venv
Make sure to use the correct command to activate your virtual environment depending on your operating system and your shell.

Your virtual environment will use the version of Python that was used to create it.

# Try running pip install in verbose mode

If none of the suggestions helped, try running the pip install command in verbose mode.

shell
pip install tensorflow -vvv