'How to resolve the error of legacy-install-failure?

 building 'matplotlib.ft2font' 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.
╰─> matplotlib

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


Solution 1:[1]

You need to download Microsoft C++ Build Tools and install it in your system then select Workloads and check the option of Desktop development using C++ . Once this is complete, you can run the installation command again.

OR

You can also choose to download this python library from Unofficial Windows Binaries for Python Extension Packages

  1. Download the file with name pip install matplotlib?3.5.1?cp38?cp38?win_amd64.whl Screenshot
  2. After downloading the file, open cmd in that folder and run the command:
  3. pip install matplotlib?3.5.1?cp38?cp38?win_amd64.whl

Similar answer

Solution 2:[2]

enter image description here

You need to download Microsoft C++ Build Tools and install it in your system then select Workloads and check the option of Desktop development using C++ .

pip install -r requirements.txt

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 satvik
Solution 2 Kamol Boymatov