How to fix Python error: legacy-install-failure

Reading time: 5 minutes
When running a pip install command, you might encounter a Python error that says:
In my experience, this error occurs when the package you’re trying to install doesn’t support the latest Python version.
To resolve this error, you might need to upgrade Python build tools (pip, setuptools, and wheel) to the latest versions.
Usually, there are hints on the error output that shows precisely why this error occurs. This tutorial will show you how to fix the error in practice.
1. Upgrade pip and other build tools
Before you run another install, try to upgrade your pip , wheel , and setuptools to the latest version first:
Once you upgraded these packages, try installing the package again.
If successful, you can skip the solutions below.
2. Check if the package was moved to a different name
This error can appear when the package you want to install was moved to a different name. You need to check the error output to see if this is true.
For instance, I tried to install the locustio package when I got this error:
The output above says that the package has moved from locustio to locust , so I changed the package name when running pip install like this:
The installation went smoothly and I no longer receive the error. You might see the same output.
3. For macOS: Ensure you have an active developer path
If you’re on Mac, you might require the Xcode Command Line Tools to fix this error.
You can tell if you need the tools when you have this error message:
The above error means you need to install the Xcode Command Line Tools.
Run the following command:
And you should be able to install the package without issue.
4. For Windows: You need to have Microsoft C++ Build Tools
If you’re on Windows, you might require Microsoft Visual C++ compiler to fix this error.
The error message should tell you as shown below:
You need to install the compiler version that’s compatible with your Python version:
Compiler 14.x for Python 3.5 — 3.10 Compiler 10.0 for Python 3.3 — 3.4 Compiler 9.0 for Python 2.6-2.7, 3.0 — 3.2
The compiler is included in Microsoft Visual Studio, so you can install Visual Studio and activate Python development workload as follows:

You can also activate Data Science workload as an extra.
If you already have Visual Studio installed, activate the workload from the menu Tools > Get Tools and Features.
Alternatively, you can also install stand-alone Microsoft C++ Build Tools.
Once you have the build tools installed, you should be able to install the package.
5. See if the package has a wheel distribution
If you still can’t install the package, you can try to download the wheel distribution and install it directly on your computer
For example, suppose you want to install the gensim package. You can look into the pypi.org files directory as shown below:

You need to download the right wheel distribution for your system. If you use Windows, download the file with win_ in its name.
macOS should use the macosx_ packages ( x86_64 for Intel Mac, universal for Apple Silicon)
Finally, Linux users should use the manylinux_ packages ( x86_64 for Intel devices, aarch64 for ARM devices)
After you download the file, install it using pip as follows:
A wheel package can be installed without going through the build process, so you don’t need to install the build tools anymore.
Conclusion
The error: legacy-install-failure occurs when the package you’re trying to install is not compatible with the Python version you installed.
You might not have the latest versions of Python build tools installed. Or the package may have been moved to a different name.
When all else fails, try to download the .whl package directly from pypi.org and install it yourself.
I hope this article helps. Thanks for reading!
Take your skills to the next level ⚡️
I’m sending out an occasional email with the latest tutorials on programming, web development, and statistics. Drop your email in the box below and I’ll send new stuff straight into your inbox!
About
Hello! This website is dedicated to help you learn tech and data science skills with its step-by-step, beginner-friendly tutorials.
Learn statistics, JavaScript and other programming languages using clear examples written for people.
Search
Type the keyword below and hit enter
Tags
Click to see all tutorials tagged with:
python pip: «error: legacy-install-failure»
I want to install gensim python package via pip install gensim But this error occurs and I have no idea what should I do to solve it.
running build_ext building 'gensim.models.word2vec_inner' extension 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/ [end of output] note: This error originates from a subprocess, and is likely not a problem with pip. error: legacy-install-failure × Encountered error while trying to install package. ╰─> gensim note: This is an issue with the package mentioned above, not pip. hint: See above for output from the failure.
asked Feb 28, 2022 at 13:37
3,352 6 6 gold badges 38 38 silver badges 67 67 bronze badges
Microsoft Visual C++ 14.0 or greater is required. Get it with «Microsoft C++ Build Tools»: visualstudio.microsoft.com/visual-cpp-build-tools do as the tip says.
Package installation issues
You might encounter a problem when installing a Python package in the project settings or in the Python Package tool window. Eventually, most of the issues are out of IDE control as PyCharm uses the pip package manager to perform the actual installation.
This article provides troubleshooting tips and covers some typical cases.
Install a package using the Terminal
The most viable troubleshooting action is to try installing the problematic package on the selected Python interpreter using the terminal. If you get an identical error message, then the problem is not in the IDE and you should review the rationales and typical cases, or search for a solution on the Internet.
Install a package on a virtual environment
- Press Control+Alt+S to open the IDE settings and then select Project | Python Interpreter .
- Expand the list of the available interpreters and click Show All .

- Locate the target interpreter and copy the path to the virtual environment.

- Open the system terminal (not the PyCharm’s built-in one) and run the following commands:
source /Scripts/activate pip install

source /bin/activate pip install

Install a package on a conda environment
- If you didn’t change the default conda environment name when configuring the interpreter, you can use the project name. Otherwise, do the following:
- Press Control+Alt+S and go to Project: | Python Interpreter .
- Expand the list of the project interpreters and scroll it down, then select Show All .
- Locate the interpreter, press Rename , and copy the environment name.
- Open the system terminal (not the PyCharm’s built-in one) and run the following commands:
activate conda install
conda activate conda install
source activate conda install
conda activate conda install
For more information about activating an environment, refer to conda documentation.
One of the possible failure cases occurs when the target package is not available in the repositories supported by the conda package manager.
Install a package on a system interpreter
- To check the path of the currently selected system interpreter that you were trying to install a package on, press Control+Alt+S and go to Project: | Python Interpreter .
- Expand the list of the available interpreters and click Show All .

- Locate the interpreter and copy the path.

- Open the system terminal (not the PyCharm’s built-in one) and run the following commands:
-m pip install

You might need the admin privileges to install packages on a system interpreter.
Parse the results
The package cannot be installed because the Python version doesn’t satisfy the package requirement.
Try to create another Python interpreter that is based on the Python version that meets the requirement.
The package cannot be installed because you don’t have permissions to install it.
Try to install the package using super-user privileges, for example, sudo pip install .
The package cannot be installed because the package is not available in the repository that is supported by the selected package manager. Example: you’re trying to install a package that is not available in the conda package manager repositories.
Try to configure another type of Python interpreter for your project and install the package on it. See how to add and modify a Python interpreter in Configure a Python interpreter.
The package cannot be installed and it matches one of the typical package installation failure cases.
Check the cases and apply related workarounds.
The package is successfully installed.
File an issue in the PyCharm issue tracker and provide explicit details about the case including all console output, error messages, and screenshots indicating that you tried to install the package on the same interpreter in the terminal and in the project settings or in the Python Packages tool window.
Review typical cases
fatal error: ‘SDL.h’ file not found
Installation fails because the package requires SDL, and pip cannot detect it. Try the following commands:
brew install sdl sdl_image sdl_mixer sdl_ttf portmidi; pip3 install pygame; pip install pygame
Cannot open include file: ‘portaudio.h’
Try to run the following commands using the admin privileges:
pip install pipwin pipwin install pyaudio
SSL module in Python is not available
Install an openssl library by the way specific to your operating system. See the detailed solutions.
Legacy install failure что делать
Last updated: Feb 23, 2023
Reading time · 10 min

# Error: legacy-install-failure with pip install [Fixed]
To solve the «Error: legacy-install-failure»:
- Upgrade your versions of pip , setuptools and wheel before running pip install .
- Check if your Python version is supported by the package.
- On Windows, download and install the package from unofficial binaries.
- Try to install the package with the —pre option.
Copied!Failed to build X Installing collected packages: X × Running setup.py install for X did not run successfully. │ exit code: 1 note: This error originates from a subprocess, and is likely not a problem with pip. error: legacy-install-failure × Encountered error while trying to install package. ╰─> X
# Upgrade your versions of pip , setuptools and wheel
First, try to upgrade your pip, setuptools and wheel versions before running the pip install command.
Here are the commands for upgrading pip on all operating systems.
Which command works depends on your operating system and your version of Python.
Copied!# ️ 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 pip is upgraded, try to run the pip install command.
Copied!pip install requests pip3 install requests python -m pip install requests python3 -m pip install requests