How to Uninstall a Python Package With Pip: Step-by-Step Guide

Download Article
Easily uninstall Python packages using Pip on any operating system
Download Article


Are you trying to use Pip to uninstall a Python package? Thankfully, whether you're on Windows, macOS, or Unix (Linux) this is a simple task. In this article we'll go over all the steps to uninstall a package with Pip, including some optional steps to remove dependencies or globally-installed packages.

Quick Pip Uninstallation Steps

  1. Open your terminal or command prompt.
  2. Start the command with python (Unix/macOS) or py (Windows).
  3. Write pip -m uninstall [packagename].
  4. Press Enter/Return to execute the command.
  5. Type y to confirm the uninstallation.
  1. How.com.vn English: Step 1 Determine which pip command to use.
    While you most commonly may use pip, there are different pip commands you can use depending on your circumstances:
    • pip: Python 2.7
    • pip3.4: Python 3.4
    • pip3.6: Python 3.6
  2. How.com.vn English: Step 2 Open a terminal or command window.
    The program you open to use Pip depends on your operating system.
    Advertisement
  3. How.com.vn English: Step 3 Enter the pip uninstall command.
    If you're on Unix or macOS, start your command with python. If you're on Windows, start it with py. Then, write the following command:
    • -m pip uninstall [packagename][1]
      • Replace pip with one of the alternatives in step 1, if necessary.
      • Replace [packagename] with the name of the package you want to uninstall.
  4. How.com.vn English: Step 4 Execute the command, then type y to continue.
    The terminal will ask if you want to proceed when you attempt to uninstall a file. Type y to proceed (or no to cancel the uninstall).
  5. How.com.vn English: Step 5 Uninstall the package globally, if necessary.
    If you installed a package globally as well as locally, uninstalling it globally is necessary to cleanly remove the package from your computer.
    • Windows: After entering the command window, press Ctrl+ Shift+ Enter to get admin privileges, then execute the pip uninstall [packagename] command again.
    • Unix/macOS: After opening a terminal window, execute the command sudo su pip uninstall [packagename].
  6. How.com.vn English: Step 6 Uninstall package dependencies, if necessary.
    Some packages also install dependencies, and these are not removed when you uninstall a package. There are two ways you can remove dependent packages:
    • Run a pip uninstall requirements.txt command. If the requirements file is not named requirements.txt, change the command to the proper requirements file name.
    • Run pip show [packagename] to see the dependencies for the given package. You can then use pip uninstall to uninstall these packages.
      • Always make sure the dependent packages are not dependencies for other packages you still have installed.
  7. Advertisement

Expert Q&A

Ask a Question
200 characters left
Include your email address to get a message when this question is answered.
Submit
      Advertisement

      Tips

      • Pure distutils packages installed with setup.py install and script wrappers installed with setup.py develop cannot be removed with pip.
      Submit a Tip
      All tip submissions are carefully reviewed before being published
      Thanks for submitting a tip for review!
      Advertisement

      About This Article

      How.com.vn English: Matt Ham
      Co-authored by:
      Computer Repair Specialist
      This article was co-authored by Matt Ham and by How.com.vn staff writer, Hannah Dillon. Matt Ham is a Computer Repair Specialist and the CEO and President of Computer Repair Doctor. With over a decade of experience, Matt specializes in Mac, PC, iPhone, iPad, and Smartphone repairs and upgrades. Matt holds a BS in Mechanical Engineering from North Carolina State University and an MS in Mechanical Engineering from Columbia University. Matt has expanded Computer Repair Doctor to seven different locations. He is also a Co-Owner of Repair Life, a full-scale marketing agency specializing in driving both online and offline leads to cell phone and computer repair shops and device retailers. This article has been viewed 4,404 times.
      How helpful is this?
      Co-authors: 4
      Updated: March 9, 2024
      Views: 4,404
      Categories: Python
      Thanks to all authors for creating a page that has been read 4,404 times.

      Is this article up to date?

      ⚠️ Disclaimer:

      Content from Wiki How English language website. Text is available under the Creative Commons Attribution-Share Alike License; additional terms may apply.
      Wiki How does not encourage the violation of any laws, and cannot be responsible for any violations of such laws, should you link to this domain, or use, reproduce, or republish the information contained herein.

      Notices:
      • - A few of these subjects are frequently censored by educational, governmental, corporate, parental and other filtering schemes.
      • - Some articles may contain names, images, artworks or descriptions of events that some cultures restrict access to
      • - Please note: Wiki How does not give you opinion about the law, or advice about medical. If you need specific advice (for example, medical, legal, financial or risk management), please seek a professional who is licensed or knowledgeable in that area.
      • - Readers should not judge the importance of topics based on their coverage on Wiki How, nor think a topic is important just because it is the subject of a Wiki article.

      Advertisement