Legacy install failure что делать
Перейти к содержимому

Legacy install failure что делать

  • автор:

How to fix Python error: legacy-install-failure

Last Updated Apr 21, 2023

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:

Visual Studio activate Python workload

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:

Python available wheel packages

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:

Resolving the Python Error: legacy-install-failure

When working with Python and using the pip install command to install packages, you may encounter an error message that says “error: legacy-install-failure”. This error typically occurs when the package you are trying to install is not compatible with the version of Python you are using.

In this article, we will explore the possible causes of this error and provide step-by-step solutions to resolve it.

What is “error:legacy-install-failure” error?

The “error: legacy-install-failure” is an error message that can occur while using Python’s pip install command to install a package. This error indicates that the installation process has failed due to compatibility issues between the package and the version of Python being used.

This error typically occurs when the package you are trying to install is not compatible with the Python version you have installed on your system. It could be due to outdated build tools, package name changes, missing developer tools on macOS, or the absence of Microsoft C++ Build Tools on Windows.

To resolve this error, you can try upgrading your pip, setuptools, and wheel packages to their latest versions, ensuring that you have the necessary developer tools installed on macOS, or installing the Microsoft C++ Build Tools on Windows. Additionally, checking if the package has been renamed or downloading and installing the package’s wheel distribution manually can also help resolve the issue.

How to fix Python error: legacy-install-failure

To address this issue, it may be necessary to update the Python build tools (pip, setuptools, and wheel) to their most recent versions.

Typically, the error output provides clues that indicate the specific reason behind this error. This tutorial will guide you through the process of resolving the error effectively.

Upgrade pip and other build tools

One common cause of the “legacy-install-failure” error is outdated build tools. Before attempting any further solutions, it is recommended to upgrade pip , setuptools , and wheel to their latest versions. Use the following commands to upgrade these tools:

pip install –upgrade pip
pip install –upgrade setuptools wheel

Check if the package was moved to a different name

Sometimes, the package you are trying to install may have been renamed. Check the error output for any hints about the package’s new name. If the error message suggests a different package name, use the new name when running the pip install command.

For macOS: Ensure you have an active developer path

If you are using macOS and encounter an error related to an invalid active developer path, it means you need to install the Xcode Command Line Tools.

Follow these steps to install the tools:

This will prompt you to install the necessary tools, and once installed, you should be able to proceed with the package installation.

For Windows: Install Microsoft C++ Build Tools

Windows users may encounter an error message stating that “Microsoft Visual C++ 14.0 or greater is required.” To resolve this, you need to install the Microsoft C++ Build Tools, which include the necessary compiler for Python. Follow these steps:

  • Visit the Microsoft Visual Studio website and download the appropriate version of the build tools for your Python version.
  • Install the build tools, ensuring that you select the Python development workload during the installation process.
  • Alternatively, if you already have Visual Studio installed, you can activate the Python development workload from the “Tools > Get Tools and Features” menu.

See if the package has a wheel distribution:

If the previous solutions did not resolve the error, you can try downloading the wheel distribution of the package and installing it manually. Follow these steps:

  • Visit the package’s page on pypi.org.
  • Look for the “Files” section and find the appropriate wheel distribution for your operating system.
  • Download the wheel file (.whl) for your system.

Once downloaded, navigate to the directory where the wheel file is located and run the following command:

pip install package-name.whl

Replace package-name with the actual name of the package you are trying to install.

Conclusion

The “legacy-install-failure” error in Python often occurs when the package you are attempting to install is not compatible with your Python version. By following the steps outlined in this article, you should be able to resolve this error and successfully install the desired package.

Remember to upgrade your build tools, check for package name changes, ensure the necessary developer tools are installed on macOS, install the Microsoft C++ Build Tools on Windows, and consider using a wheel distribution if other solutions fail.

We hope this article has been helpful in resolving the “legacy-install-failure” error. Happy coding!

Не могу установить библиотеку через pip что делать?

Collecting simpleaudio
Using cached simpleaudio-1.0.4.tar.gz (2.0 MB)
Preparing metadata (setup.py) . done
Installing collected packages: simpleaudio
DEPRECATION: simpleaudio is being installed using the legacy ‘setup.py install’ method, because it does not have a ‘pyproject.toml’ and the ‘wheel’ package is not installed. pip 23.1 will enforce this behaviour change. A possible replacement is to enable the ‘—use-pep517’ option. Discussion can be found at https://github.com/pypa/pip/issues/8559
Running setup.py install for simpleaudio . error
error: subprocess-exited-with-error

× Running setup.py install for simpleaudio did not run successfully.
│ exit code: 1
╰─> [20 lines of output]
running install
C:\Users\user\AppData\Local\Programs\Python\Python311\Lib\site-packages\setuptools\command\install.py:34: SetuptoolsDeprecationWarning: setup.py install is deprecated. Use build and pip and other standards-based tools.
warnings.warn(
running build
running build_py
creating build
creating build\lib.win-amd64-cpython-311
creating build\lib.win-amd64-cpython-311\simpleaudio
copying simpleaudio\__init__.py -> build\lib.win-amd64-cpython-311\simpleaudio
copying simpleaudio\shiny.py -> build\lib.win-amd64-cpython-311\simpleaudio
copying simpleaudio\functionchecks.py -> build\lib.win-amd64-cpython-311\simpleaudio
creating build\lib.win-amd64-cpython-311\simpleaudio\test_audio
copying simpleaudio\test_audio\c.wav -> build\lib.win-amd64-cpython-311\simpleaudio\test_audio
copying simpleaudio\test_audio\e.wav -> build\lib.win-amd64-cpython-311\simpleaudio\test_audio
copying simpleaudio\test_audio\g.wav -> build\lib.win-amd64-cpython-311\simpleaudio\test_audio
copying simpleaudio\test_audio\left_right.wav -> build\lib.win-amd64-cpython-311\simpleaudio\test_audio
copying simpleaudio\test_audio\notes_2_16_44.wav -> build\lib.win-amd64-cpython-311\simpleaudio\test_audio
running build_ext
building ‘simpleaudio._simpleaudio’ extension
error: Microsoft Visual C++ 14.0 or greater is required. Get it with «Microsoft C++ Build Tools»: https://visualstudio.microsoft.com/visual-cpp-buil.
[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.
╰─> simpleaudio

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

  • Вопрос задан 14 апр.
  • 1420 просмотров

1 комментарий

Простой 1 комментарий

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,223 5 5 gold badges 35 35 silver badges 59 59 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.

Добавить комментарий

Ваш адрес email не будет опубликован. Обязательные поля помечены *