Fix: error: legacy-install-failure Python pip/pip3


Error:
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.

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

If you get the error legacy-install-failure when trying to install a Python package using pip, you can try to fix it by following the below options.

  1. If you are using Python3 make use of pip3 instead of pip and see if it works.
  2. Make sure that the pip/pip3 installations is up-to-date. If not update using the below command.

    For pip:
    pip install --upgrade pip
    
    or
    
    python -m pip install --upgrade pip
    For pip3:
    pip3 install --upgrade pip
    
    or
    
    python3 -m pip install --upgrade pip
  3. In the same way, next you update the setuptools and wheel.

    For pip:

    pip install --upgrade setuptools wheel

    For pip3:

    pip3 install --upgrade setuptools wheel

  4. Try to create a virtual environment and then install the package within that environment, as this can help to isolate your project dependencies and avoid conflicts.

    Step 1: Create a virtual environment
    python3 -m venv myenv
    Step 2: Activate the virtual environment:
      Linux/Mac
      source myenv/bin/activate
      Windows
      .\myenv\Scripts\activate
    Step 3: Now try to install the package within the virtual environment
    pip3 install package-name

Hope you find this helpful. If not please leave a comment, I am happy to help!

Facing issues? Have Questions? Post them here! I am happy to answer!

Author Info:

Rakesh (He/Him) has over 14+ years of experience in Web and Application development. He is the author of insightful How-To articles for Code2care.

Follow him on: X

You can also reach out to him via e-mail: rakesh@code2care.org

Copyright © Code2care 2024 | Privacy Policy | About Us | Contact Us | Sitemap