Python uninstall all modules

PIP Uninstall All Python Packages in Windows – See a Full Guide! [MiniTool Tips]

If you have installed a Python package, you want to uninstall it due to some reason. Then, how to uninstall Python package with PIP? After reading this detailed guide on PIP uninstall given by MiniTool, you know what you should do.

What Is PIP?

Before introducing something on how to uninstall PIP packages, let’s first see a general introduction to Python PIP.

PIP is a package manager in Python that is used to install and manage Python packages. This tool allows you to install and manage Python applications and their dependencies. Package management is very important, so PIP is pre-installed in most Python distributions. By default, Python 3.4 and later & Python 2.7.9 and later (on the Python2 series) include PIP.

If you install a Python package, due to some reason, you may want to uninstall it. Well then, how to uninstall Python package with PIP? Follow the guide here now to know some details.

Читайте также:  Эффект при скролле css

PIP Uninstall Package – How to Do in Windows

In this part, we show you some commands to uninstall PIP packages, and let’s see them one by one.

PIP Uninstall Packagename

Using this command, you can remove the installed package one by one. This method only works when you have already added Python to the Windows path. If you don’t know how to add it, you can go to press Win + R, type sysdm.cpl and click OK to open System Properties. Go to Advanced > Environment Variables. Under User variables, click New, and edit Variable name and Variable value.

In terms of Variable value, it should include the Python application path and Python Scripts path. To find them, right-click on your Python app (which can be found via the Windows search bar) and choose Open file location. Then, right-click on the Python shortcut and choose Open file location. The app path can be seen like C:\Users\cy\AppData\Local\Programs\Python\Python311. The Scripts path should be C:\Users\cy\AppData\Local\Programs\Python\Python311\Scripts.

How to Fix PIP Is Not Recognized in Windows Command Prompt?

If you get the error “’pip’ is not recognized as an internal or external command”, what should you do? This post gives you some solutions.

add Python to Windows path

Next, see how to uninstall PIP.

Step 1: In Windows, open Command Prompt with admin rights.

How to Open Command Prompt (CMD) in Windows 11? (7 Ways)

How to open Command Prompt (CMD) in Windows 11? If you are looking for methods to open this tool, read this post and you can find some ways.

Step 2: Type cd\ into the CMD window and press Enter.

Step 3: Type cd followed by the Python Scripts path and here is an example — cd C:\Users\cy\AppData\Local\Programs\Python\Python311\Scripts. Then, press Enter.

Step 4: Execute this command — pip uninstall package_name. Replace the package name with the one you have installed like pandas. See an example pip uninstall pandas.

PIP uninstall package

Step 5: Type y to confirm the uninstallation when asked. Now, your Python package is removed from your computer.

PIP Uninstall All Packages

If you want to delete all the packages installed by PIP, you can use the pip freeze command. It can help you list all the installed packages via PIP and uninstall them without asking for confirmation. The correct type of this command is pip uninstall -y -r <(pip freeze).

If you want, you can save the installed packages in a file called requirements.txt and directly uninstall PIP packages from the file. Run these commands:

pip freeze > requirements.txt

pip uninstall -r requirements.txt This helps to uninstall packages one by one.

pip uninstall -r requirements.txt -y This helps to delete all the packages at once.

In addition to pip freeze, you can also use xargs to uninstall all the PIP packages. The command is pip freeze | xargs pip uninstall -y. If you have packages installed via VCS (like GitLab, Github, Bitbucket, etc.), you need to exclude them and then uninstall Python packages with PIP via this command — pip freeze | grep -v «^-e» | xargs pip uninstall -y.

Final Words

How to uninstall Python package with PIP or how to uninstall PIP packages? After reading this guide on PIP uninstall, try the given ways to easily remove packages from your Windows computer if you need. If you have any ideas, let us know in the comment part.

About The Author

Vera is an editor of the MiniTool Team since 2016 who has more than 5 years’ writing experiences in the field of technical articles. Her articles mainly focus on disk & partition management, PC data recovery, video conversion, as well as PC backup & restore, helping users to solve some errors and issues when using their computers. In her spare times, she likes shopping, playing games and reading some articles.

Источник

How to Uninstall Python Packages

All Python package management solutions provide the basic function of uninstalling packages, including pip, pipenv and the ActiveState Platform. However, unless specifically defined in a requirements.txt or pipfile.lock, package managers will not deal with transitive dependencies (ie., dependencies of dependencies).

In this article, we explain how to uninstall Python packages using these popular tools and we also introduce you to the ActiveState Platform. The AS Platform is unique in automatically installing and uninstalling transitive dependencies. Our dependency management system makes it possible to track conflicts between packages, know about platform-specific dependencies, and even track system-level dependencies like C and C++ libraries. Once you are done reading, you can try the ActiveState Platform by signing up for a free account .

Read on to understand how to work with Pip and Pipenv Package Managers to uninstall Python packages.

Checklist

Before packages can be uninstalled, ensure that a Python installation containing the necessary files needed for uninstalling packages is in place. Installation Requirements (for Windows).

How to Uninstall Packages Installed with Pip

How to Uninstall Packages in a Python Virtual Environment

Packages can be uninstalled from a virtual environment using pip or pipenv.

To use pip to uninstall a package locally in a virtual environment:

  1. Open a command or terminal window (depending on the operating system)
  2. cd into the project directory
  3. pip uninstall

To use pipenv to uninstall a package locally in a virtual environment created with venv or virtualenv:

  1. Open a command or terminal window (depending on the operating system)
  2. cd into the project directory
  3. pipenv uninstall

How to Globally Uninstall Python Packages

In some cases, packages may be installed both locally (e.g., for use in a specific project) and system-wide. To ensure a package is completely removed from your system after you’ve uninstalled it locally, you’ll also need to uninstall it globally.

To uninstall a package globally in Windows:

    1. Open a command window by entering ‘cmd’ in the Search Box of the Task bar
    2. Press Ctrl+Shift+Enter to gain Administration (Admin) privileges
    3. pip uninstall

    To uninstall a package globally in Linux:

    How to Uninstall Package Dependencies with Pip

    When you install a package with pip, it also installs all of the dependencies the package requires. Unfortunately, pip does not uninstall dependencies when you uninstall the original package. Here are a couple of different procedures that can be used to uninstall dependencies.

    1. If a package has been installed via a pip requirements file (i.e., pip install requirements.txt ), all of the packages in requirements.txt can be uninstalled with the following command:
    pip uninstall requirements.txt
    1. If a requirements.txt file is not available, you can use the pip show command to output all the requirements of a specified package:

    Output should be similar to:

    These dependencies can then be uninstalled with the pip uninstall command. However before uninstalling, you should ensure that the packages are NOT dependencies for other existing packages.

    How to Uninstall Package Dependencies with Pipenv

    To uninstall all the dependencies in a Pipenv project:

    1. Open a command or terminal window
    2. cd into the project directory
    3. pipenv uninstall —all

    How to Uninstall a Package Installed With Setuptools

    Any packages that have been configured and installed with setuptools used the following command:

    Unfortunately, there is no python setup.py uninstall command. To uninstall a package installed with setup.py, use the pip command:

    Be aware that there are a few exceptions that cannot be uninstalled with pip, including:

    • Distutils packages, which do not provide metadata indicating which files were installed.
    • Script wrappers installed by the setup.py develop command.

    Next Steps

    Resolving packages when installing or uninstalling an environment can be an extremely slow (or even manual) process. You can speed things up considerably using the ActiveState Platform, which automatically resolves dependencies for you–fast! Get started free on the ActiveState Platform.

    Or just install Python 3.9 and use the included command line interface, the State Tool, to “state install” the packages you need:

    >state install numpy ╔════════════════════╗ ║ Installing Package ║ ╚════════════════════╝ Updating Runtime ──────────────── Changes to your runtime may require some dependencies to be rebuilt. numpy includes 2 dependencies, for a combined total of 8 new dependencies. Building 8/8 Installing 8/8 Package added: numpy

    Источник

Оцените статью