Как удалить все pip пакеты python windows

View this page

Toggle table of contents sidebar

Usage¶

Unix/macOS

python -m pip uninstall [options] <package> ...
python -m pip uninstall [options] -r <requirements file> ...

Windows

py -m pip uninstall [options] <package> ...
py -m pip uninstall [options] -r <requirements file> ...

Description¶

Uninstall packages.

pip is able to uninstall most installed packages. Known exceptions are:

  • Pure distutils packages installed with python setup.py install, which
    leave behind no metadata to determine what files were installed.

  • Script wrappers installed by python setup.py develop.

Options¶

-r, —requirement <file>

Uninstall all the packages listed in the given requirements file. This option can be used multiple times.

(environment variable: PIP_REQUIREMENT)

-y, —yes

Don’t ask for confirmation of uninstall deletions.

(environment variable: PIP_YES)

—root-user-action <root_user_action>

Action if pip is run as a root user [warn, ignore] (default: warn)

(environment variable: PIP_ROOT_USER_ACTION)

—break-system-packages

Allow pip to modify an EXTERNALLY-MANAGED Python installation

(environment variable: PIP_BREAK_SYSTEM_PACKAGES)

Examples¶

  1. Uninstall a package.

    Unix/macOS

    $ python -m pip uninstall simplejson
    Uninstalling simplejson:
       /home/me/env/lib/python3.9/site-packages/simplejson
       /home/me/env/lib/python3.9/site-packages/simplejson-2.2.1-py3.9.egg-info
    Proceed (Y/n)? y
       Successfully uninstalled simplejson
    

    Windows

    C:\> py -m pip uninstall simplejson
    Uninstalling simplejson:
       /home/me/env/lib/python3.9/site-packages/simplejson
       /home/me/env/lib/python3.9/site-packages/simplejson-2.2.1-py3.9.egg-info
    Proceed (Y/n)? y
       Successfully uninstalled simplejson
    

Пройдите тест, узнайте какой профессии подходите

Существует множество случаев, когда может возникнуть необходимость удалить все пакеты, установленные через pip в рамках определенного виртуального

Освойте Python на курсе от Skypro. Вас ждут 400 часов обучения и практики (достаточно десяти часов в неделю), подготовка проектов для портфолио, индивидуальная проверка домашних заданий и помощь опытных наставников. Получится, даже если у вас нет опыта в IT.

Существует множество случаев, когда может возникнуть необходимость удалить все пакеты, установленные через pip в рамках определенного виртуального окружения. Например, это может быть полезно при переходе к новой версии Python или при необходимости «почистить» рабочее пространство для нового проекта.

Чтобы удалить все пакеты, установленные через pip, можно использовать команду pip freeze, которая выводит список всех установленных пакетов, а затем передать вывод этой команды в pip uninstall с использованием параметра -y, который автоматически подтверждает удаление каждого пакета.

В общем виде команда выглядит так:

pip freeze | xargs pip uninstall -y

Она работает следующим образом:

  • pip freeze создает список всех установленных пакетов.
  • xargs берет этот список и передает каждый элемент в качестве аргумента для следующей команды.
  • pip uninstall -y удаляет каждый пакет, переданный ей xargs.

Эта команда должна быть выполнена в активированном виртуальном окружении, из которого требуется удалить пакеты. Если виртуальное окружение не активировано, эта команда удалит пакеты из глобального пространства Python, что, скорее всего, не является желаемым действием.

Важно отметить, что эта команда удалит все пакеты, включая pip, поэтому после ее выполнения может потребоваться повторная установка pip или других необходимых пакетов.

На курсе Skypro «Python-разработчик» освоите основные инструменты программирования, получите опыт на реальных проектах и сможете стартовать в профессии уверенным новичком. Преподаватели — практикующие программисты с большим опытом, а в центре карьеры помогут составить цепляющее резюме и подготовиться к собеседованию.

  • Home
  • News
  • PIP Uninstall All Python Packages in Windows – See a Full Guide!

PIP Uninstall All Python Packages in Windows – See a Full Guide!

By Vera | Follow |
Last Updated

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.

Tips:

Experience a faster system with MiniTool System Booster – your solution to effortless program uninstallation.

MiniTool System Booster TrialClick to Download100%Clean & Safe

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.

add Python to Windows path

Next, see how to uninstall PIP.

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

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

Position: Columnist

Vera is an editor of the MiniTool Team since 2016 who has more than 7 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 Remove all Python packages installed by pip?


This post explains — How To Remove all Python packages installed by pip. To do that lets try the below  

Option 1:


Use below command —


pip freeze | xargs pip uninstall -y

 

Option 2:


If there are any packages which were installed usig VCS,  then we will exclude those . And then will remove the packages


pip freeze | grep -v "^-e" | xargs pip uninstall -y

 

Option 3:


  • Get the list of all Python pip package in the requirements.txt file — Note: This OVERWRITES the Existing requirements.txt else will create new one.

pip freeze > requirements.txt

  • Remove all packages — one by one

pip uninstall -r requirements.txt

  • Remove all packages at once —

pip uninstall -r requirements.txt -y

  Hope This post helps to explain — How To Remove all Python packages installed by pip.   Additional Reads:

  • How To Set up Apache Spark & PySpark in Windows 10
  • How To Save & Reload a Python Machine Learning Model using Pickle ?

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

To uninstall a package: 

pip uninstall <packagename>

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 <packagename>

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 <packagename>

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 <packagename>
  1.  

To uninstall a package globally in Linux:

    1. Open a terminal window
    2. sudo su pip uninstall <packagename>

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:
pip show <packagename>

Example:

pip show cryptography

Output should be similar to: 

'Requires: six, cffi'

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: 

python setup.py install 

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

pip uninstall <packagename>

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

Python 3.9 Web GUI Graphic

Понравилась статья? Поделить с друзьями:
0 0 голоса
Рейтинг статьи
Подписаться
Уведомить о
guest

0 комментариев
Старые
Новые Популярные
Межтекстовые Отзывы
Посмотреть все комментарии
  • Windows server 2012 сертификат сервера
  • Точка восстановления windows 10 где найти на ноутбуке
  • Как посмотреть проброс портов windows
  • Screensaver windows 10 камин
  • Как отключить windows defender через cmd