Resolving Python error: legacy-install-failure – Code Example

Total
0
Shares

Error: legacy-install-failure is a python error which is raised during installation of some library using pip install command. Primary reasons for this error are –

  1. Incompatible library wheel.
  2. Required version of Microsoft Visual C++ isn’t installed.
  3. python3-dev library is missing.
  4. Not using pacman package manager in arch linux.

Solution

Using compatible wheel package will resolve this error. Wheel packages are the driving tools for the seamless installation on different operating systems, hardware and software stack.

For gensim, you might get this error –

      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.

Along with legacy-resolve-failure error this code is also getting error originates from a subprocess, and is likely not a problem with pip error.

To resolve legacy-resolve-failure error you can download the gensim wheel from here. The naming conventions are – gensim‑4.2.0‑cp39‑cp39‑win_amd64.whl, where cp39 means python 3.9, win means windows and amd64 means 64 bit operating system.

Similarly, you can download the wheels for other libraries. We are providing the list of all the known libraries to us. Choose the one which you are trying to install and getting error. This list is for windows operating system –

Conclusion

Python wheels are the packages which can simplify the installation of libraries. In case of incompatibility among hardware and software stacks, these wheels helps a lot.

In case of MacOS, always accept the update confirmation in your xcode. This error sometimes appears due to that.