How to remove all pip packages

How to remove all pip packages

Каков самый простой способ удалить все пакеты, установленные в pip?

Есть ли быстрый и простой способ сделать это с помощью pip?

ОТВЕТЫ

Ответ 1

Я нашел этот фрагмент в качестве альтернативного решения. Это более грациозное удаление библиотек, чем обновление виртуального файла:

Если у вас есть пакеты, установленные через VCS, вам нужно исключить эти строки и удалить пакеты вручную (повышенные из комментариев ниже):

Ответ 2

Это будет работать для всех систем Mac, Windows и Linux. Чтобы получить список всех пакетов pip в файле needs.txt (Примечание. Это перезапишет файл require.txt, если он существует, иначе создаст новый).

Теперь, чтобы удалить один за другим

Если мы хотим удалить все сразу, то

И для одной команды без создания какого-либо файла (как предложил joeb).

Ответ 3

Я думаю, что это работает с последними

Но обычно я просто удаляю и воссоздаю virtualenv.

Ответ 4

Я хотел поднять этот ответ из секции комментариев, потому что это одно из самых элегантных решений в этой ветке. Полная оценка этого ответа идет на @joeb.

Это прекрасно сработало для случая использования очистки папки пользовательских пакетов вне контекста virtualenv, который многие из приведенных выше ответов не обрабатывают.

Изменение: Кто-нибудь знает, как заставить эту команду работать в Makefile?

Бонус: псевдоним Bash

Я добавляю это в свой профиль bash для удобства:

Альтернатива для пипенв

Если вы используете pipenv, вы можете просто запустить:

Ответ 5

Так вот фрагмент, который я регулярно использую

Ответ 6

Способ 1 (с pip freeze )

Способ 2 (с pip list )

Способ 3 (с virtualenv )

Ответ 7

Ответ 8

В Windows, если ваш path настроен правильно, вы можете использовать:

Он должен быть похож на Unix-подобные системы:

Просто предупреждение о том, что это не совсем твердо, поскольку вы можете столкнуться с такими проблемами, как «Файл не найден», но он может работать в некоторых случаях, тем не менее

Файл окончательно удаляется после завершения.

Ответ 9

Ответ 10

Во-первых, добавьте весь пакет в requirements.txt

Затем удалите все

Ответ 11

Это старый вопрос, который я знаю, но я наткнулся на него, поэтому для дальнейшего использования вы можете сделать это:

Удалите все пакеты, указанные в данном файле требований. Эта опция может быть использована несколько раз.

Ответ 12

Для пользователей Windows это то, что я использую в Windows PowerShell

Ответ 13

(добавив это как ответ, потому что у меня недостаточно репутации, чтобы комментировать ответ @blueberryfields)

Если стандартный ввод не содержит небланков, не запускайте команду. Обычно команда запускается один раз, даже если нет ввода. Эта опция является расширением GNU.

Ответ 14

Это был самый простой способ удалить все пакеты python.

Ответ 15

Поддержка кросс-платформы с помощью только pip :

Ответ 16

Это команда, которая работает для меня:

Ответ 17

Если вы используете virtualenv :

если вы не знаете, где находится ваше виртуальное env, вы можете запустить which python из активированного виртуального env, чтобы получить путь

Ответ 18

В моем случае я случайно установил несколько пакетов по всему миру с помощью установленного Homebrew pip на macOS. Самый простой способ вернуться к пакетам по умолчанию был простым:

Или, если вы использовали pip3 :

Ответ 19

Ответ 20

pew wipeenv [env]

Ответ 21

легкий надежный способ кросс-платформенный и работа в pipenv, а также:

но не будет обновлять piplock или pipfile, так что имейте в виду

Ответ 22

Ответ 23

Пип не знает, какие пакеты были установлены им и какие пакеты были установлены вашим диспетчером системных пакетов. Для этого вам нужно будет сделать что-то вроде этого

для rpm-based distros (замените python2.7 на вашу версию python, на которой вы установили pip):

для распределения на основе deb:

затем очистить оставшиеся пустые каталоги:

Я нашел верхний ответ очень вводящим в заблуждение, так как он удалит все (большинство?) пакетов python из вашего дистрибутива и, вероятно, оставит вас с разбитой системой.

How To Manage Python Packages Using PIP

PIP, the python package manager, is used to install, upgrade, remove packages written in Python programming language. In this guide, we will be discussing how to install pip and manage python packages such as installing, updating, and removing packages using pip. Additionally, we will see what is virtual environment, how to create it, and how to isolate packages in the virtual environment using venv and/or virtualenv tools.

Install pip using package managers

On Arch Linux and its variants like Antergos, Manjaro Linux, you can install pip using command:

Python 2:

Python 3:

On Fedora 21:

Python 2:

Python 3:

Fedora 22:

Python 2:

Python 3:

To get newer versions of pip, setuptools, and wheel for Python 2, enable the PyPA Copr Repo using command:

On CentOS/RHEL:

Pip and wheel is not available in the default repositories of CentOS and RHEL. To install pip on CentOS, RHEL, Scientific Linux and other RPM based systems, enable EPEL repository using command:

And then run the following command to install pip:

Since setup-tools package is available in the default repositories, you can install it using command:

Python 3:

openSUSE:

Python 2:

Python 3:

Debian/Ubuntu:

For Python 2.x:

For Python 3.x:

Replace “python” with “python3” for installing Python 3.x version.

In Ubuntu 12.04 version, pip3 didn’t come packaged. If you’re using Ubuntu 12.04, you can install pip3 using the following commands:

Installing pip from binaries

If you’d like to install pip from binaries, just run:

Please note that get-pip.py will also install setuptools and wheel. As I mentioned earlier, some Linux distros doesn’t has wheel in the core repositories. In such cases, you may need to add some third party repositories, for example EPEL.

pip is already installed if you’re using Python 2 >=2.7.9 or Python 3 >=3.4 binaries downloaded from python.org. However, you will need to upgrade pip using command:

To update all (pip, setuptools, whell), run:

To find out the installed version of pip/pip3, run:

Sample output would be:

Creating Virtual Environments

Before installing any python packages, it is recommended to create a virtual environment. Why do we need to create virtual environment? You might ask. Because, the Python “Virtual Environments” allows us to install a Python package in an isolated location, rather than installing it globally.

Let us say you want to install a python package, for example youtube-dl, that needs version 1 of LibFoo, but another application requires version 2. How can you use both these applications? If you install everything into /usr/lib/python2.7/site-packages or /usr/lib/python3.6/site-packages (or whatever your platform’s standard location is), it’s easy to end up in a situation where you unintentionally upgrade an application that shouldn’t be upgraded. To avoid this, we isolate the packages in the virtual environment. All virtual environments have their own installation directories and doesn’t interact or conflict with one another.

We can create isolated python environments using two modules, namely:

For Python 2.x, you need to install virtualenv. To do so, run:

Let us create a virtual environment now.

For Python 3.x, you need to install venv. On Ubuntu-based systems, you can install it using command:

Now create virtual environment using venv:

Once, you run the above command, you will be placed in your virtual environment immediately.

To deactivate the virtual environment and come to back to your normal shell, run:

Manage Python Packages Using Pip

Now we will see most common basic pip usage with examples.

To view the list of all pip commands and general options, run:

You should see an output something like below.

How to remove all pip packages. Смотреть фото How to remove all pip packages. Смотреть картинку How to remove all pip packages. Картинка про How to remove all pip packages. Фото How to remove all pip packages

To know what install command does, run:

The most common usage of pip is to install from the PyPi (Python Package Index). PyPi is a repository that contains all the packages created by the community of developers in Python.

Install packages

Create virtual environment first as shown below:

Replace MYENV with your own name.

Finally, activate it using command:

Once, you run the above command, you will be placed inside your virtual environment:

How to remove all pip packages. Смотреть фото How to remove all pip packages. Смотреть картинку How to remove all pip packages. Картинка про How to remove all pip packages. Фото How to remove all pip packages

Now, it is time to install some packages. To install a package, for example youtube-dl, run:

This command will install youtube-dl with all its dependencies.

How to remove all pip packages. Смотреть фото How to remove all pip packages. Смотреть картинку How to remove all pip packages. Картинка про How to remove all pip packages. Фото How to remove all pip packages

To install a specific version, run:

To install a version other than specified version, run:

Note the ‘!» in-front of equal symbol.

To install a version equal to or greater than the specified version, run:

To install a version in the specific range, for instance greater than or equal to one version and less than another, run:

To install a version that’s “compatible” with a certain version:

Download packages

To download a package with all dependencies (without installing it), run:

List all installed packages

To find which packages were installed by pip, run:

These commands will display all installed packages using pip in your system.

Search packages

To search for a specific package, for example youtube-dl, run:

This command will search and display the result that matches the string «youtube-dl».

Update packages

To list all outdated packages in a simple tabular column format, run:

To update an outdated package, run:

We can also dump all packages in a file and update them all in one go. First, export all files to a file:

Now update all packages at once using command:

If the above command didn’t work for any reason, use the following command to update all packages at once:

Export all installed packages in a file

Sometimes, you might want to export all installed packages in a file to test them in a different environment. To do so, run:

Now, deactivate the current virtual environment:

and create a new using commands:

Replace MYENV1 with your own name.

Activate the newly created environment:

Now, install all packages which we exported earlier.

To install all at once without user interaction, run:

Similarly, you can remove all packages from the list using command:

View package information

To view the details of a package, run:

View package dependencies

We can visualize the dependencies of all installed packages using «pipdeptree» tool.

Install it using command:

Once installed, you can view the dependency tree using command:

How to remove all pip packages. Смотреть фото How to remove all pip packages. Смотреть картинку How to remove all pip packages. Картинка про How to remove all pip packages. Фото How to remove all pip packages

Uninstall packages

To uninstall/remove an installed package, run:

To uninstall multiple packages, specify them with comma separated like below:

To remove all python packages installed using pip, run:

Sometimes pip doesn’t allow you to uninstall packages owned by the OS. In such cases, you can uninstall all the packages which are not owned by the OS using command:

As I mentioned in the previous section, we can dump all installed packages in a file and uninstall them from the list using command:

At this stage, you might get some idea about pip and its usage. For more details, refer the official documentation and the pip help section by running the following command:

Suggested read:

And, that’s all for now. Hope this was useful.

I with pip freeze I see

when I try to uninstall the packages I get errors:

How do I uninstall such a package?

How to remove all pip packages. Смотреть фото How to remove all pip packages. Смотреть картинку How to remove all pip packages. Картинка про How to remove all pip packages. Фото How to remove all pip packages

uninstalls packages installed in the editable mode in recent versions of pip (mine is 19.1.1). Make sure to use the package name in setup.py, not the alias you specify to call that package in entry_points

6 Answers 6

Trending sort

Trending sort is based off of the default sorting method — by highest score — but it boosts votes that have happened recently, helping to surface more up-to-date answers.

It falls back to sorting by highest score if no posts are trending.

Switch to Trending sort

At /lib/python2.7/site-packages/ (if not using virtualenv then /lib/python2.7/dist-packages/ )

How to remove all pip packages. Смотреть фото How to remove all pip packages. Смотреть картинку How to remove all pip packages. Картинка про How to remove all pip packages. Фото How to remove all pip packages

An easier way to do the same with the new version of setup_tools is to run the following:

Which basically does the same as what @glarrain describes in his answer.

Here’s a demonstration, showing that eg you don’t want to substitute a package name into that command:

How to remove all pip packages. Смотреть фото How to remove all pip packages. Смотреть картинку How to remove all pip packages. Картинка про How to remove all pip packages. Фото How to remove all pip packages

How to remove all pip packages. Смотреть фото How to remove all pip packages. Смотреть картинку How to remove all pip packages. Картинка про How to remove all pip packages. Фото How to remove all pip packages

Install a dev package use cmd:

Now you can use:

How to remove all pip packages. Смотреть фото How to remove all pip packages. Смотреть картинку How to remove all pip packages. Картинка про How to remove all pip packages. Фото How to remove all pip packages

Simply uninstall the package you installed in ‘editable’ mode:

it works for recent pip-versions (at least >=19.1.1).

It turns out that my installation was somehow corrupt.

I could find the entry in:

How to remove all pip packages. Смотреть фото How to remove all pip packages. Смотреть картинку How to remove all pip packages. Картинка про How to remove all pip packages. Фото How to remove all pip packages

This is a bug on debian/ubuntu linux using OS-installed pip (v8.1.1 for me), which is what you’ll invoke with sudo pip even if you’ve upgraded pip (e.g. get-pip.py). See https://github.com/pypa/pip/issues/4438

For a discussion on how to clean up see https://askubuntu.com/questions/173323/how-do-i-detect-and-remove-python-packages-installed-via-pip, though the solutions there are of the «remove everything» variety.

. a few packages were installed in

For my system all I needed to remove was /usr/local/lib/python2.7/dist-packages/.egg-link

How to remove packages installed with older versions of Python/Pip?

I’m experiencing a issue with my packages, I installed a package with Python 3.7 and the current version of Python in my computer is 3.9. So I can’t uninstall or update the given package.

How to remove all pip packages. Смотреть фото How to remove all pip packages. Смотреть картинку How to remove all pip packages. Картинка про How to remove all pip packages. Фото How to remove all pip packages

2 Answers 2

Trending sort

Trending sort is based off of the default sorting method — by highest score — but it boosts votes that have happened recently, helping to surface more up-to-date answers.

It falls back to sorting by highest score if no posts are trending.

Switch to Trending sort

What you need to do to solve this issue is navigate to the Pip from the version that you have installed the package, in this case, 3.7, uninstall or update the package using this pip.

Now you can install the package with latest the Python in your system

This answer also provide a method for dealing with multiple python versions

How to remove all pip packages. Смотреть фото How to remove all pip packages. Смотреть картинку How to remove all pip packages. Картинка про How to remove all pip packages. Фото How to remove all pip packages

How to remove all pip packages. Смотреть фото How to remove all pip packages. Смотреть картинку How to remove all pip packages. Картинка про How to remove all pip packages. Фото How to remove all pip packages

Not the answer you’re looking for? Browse other questions tagged python pip or ask your own question.

Linked

Related

Hot Network Questions

Subscribe to RSS

To subscribe to this RSS feed, copy and paste this URL into your RSS reader.

By clicking “Accept all cookies”, you agree Stack Exchange can store cookies on your device and disclose information in accordance with our Cookie Policy.

How to Uninstall all Packages from Virtualenv Using Pip?

Python is flexible and scalable. We can install a lot of Python libraries and use them in our project without writing the code from scratch. That makes our job easy. But, that comes with the cost of managing those libraries in Python.

In this tutorial we are going learn commands to uninstall all packages from virtual environment.

I remember working on one of the projects where I have to set a virtual environment to run the project. It was a Django project.

After creating a virtual environment, I upgrade the Django library to the latest version. It also upgrades the dependent other libraries. And everything started failing.

I wanted to restore all the Python libraries to the previous version. So here are the steps I followed to uninstall Python libraries.

Activate your virtual environment from where you want to delete all the installed libraries. And then follow the below steps.

Take a Backup of Installed Libraries

You can also take the backup of the installed libraries.

It will save all the installed libraries and their versions in the file backup_requirements.txt. (You can use this file to install Python libraries anytime in future.)

Uninstall all Packages from Virtualenv using Pip Tool

You might have requirement file in your project. Run below command.

It will seek your permission to uninstall each library.

Remove All Python Libraries All At Once

You can verify if all the libraires are removed or not using pip command.

It will show all the installed libraries. In our case, it will not show any library installed.

All these commands works on Windows, MacOS and Linux systems.

This is all about this tutorial to uninstall all Packages from virtualenv. If you have specific questions or doubt, let me know in the comment, I can help you.

Источники информации:

Добавить комментарий

Ваш адрес email не будет опубликован. Обязательные поля помечены *