pip uninstall#
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.
Don’t ask for confirmation of uninstall deletions.
Action if pip is run as a root user. By default, a warning message is shown.
Как установить или удалить модуль Python?
Лучший и рекомендуемый способ установки модулей Python — использовать pip, менеджер пакетов Python.
Если у вас установлен Python 2> = 2.7.9 или Python 3> = 3.4 с python.org, у вас уже есть pip и setuptools, но вам потребуется обновить его до последней версии:
В Linux или macOS:
Если вы используете установку Python в Linux, которая управляется менеджером системных пакетов (например, «yum», «apt-get» и т. Д.), И вы хотите использовать менеджер системных пакетов для установки или обновления pip, то смотрите: https://packaging.python.org/guides/installing-using-linux-tools/
В противном случае:
Загрузите файл get-pip.py с веб-сайта https://bootstrap.pypa.io/get-pip.py. Запустите python get-pip.py. Это установит или обновит пункт.
Теперь вы можете использовать pip для установки пакетов Python. Например, чтобы установить последнюю версию «SomeProject»:
Чтобы установить конкретную версию:
Чтобы установить больше или равно одной версии и меньше другой:
Вы можете удалить большинство установленных пакетов Python, используя pip. Для получения дополнительной информации об удалении из pip перейдите по ссылке : https://pip.pypa.io/en/stable/reference/pip_uninstall/. Например, если у вас установлен пакет numpy и вы хотите удалить его, введите следующее:
Однако есть некоторые исключения. Эти пакеты не могут быть легко удалены с помощью pip:
1. Чистые пакеты distutils, установленные с помощью python setup.py install, которые не оставляют метаданных, чтобы определить, какие файлы были установлены.
2. Разработка сценариев, установленных Python setup.py.
Вам необходимо удалить все файлы вручную, а также отменить любые другие действия, которые установка выполняла вручную.
Если вы не знаете список всех файлов, вы можете переустановить его с параметром —record и взглянуть на список, который он создает. Для записи списка установленных файлов вы можете использовать:
How to delete an installed module in Python?
Python’s package manager is called PIP. In other words, it is a tool that enables us to install Python packages and dependencies (the software elements needed by your code to function without throwing any errors) that are not already available to us through the Python Standard Library.
A computer language’s tool that makes it simple to install any external dependencies is known as a package manager. Any package can be installed or uninstalled without issue.
Steps involved for uninstalling using pip
Following are the steps to uninstall a package or module using pip command −
Open the command prompt.
With the help of «PIP uninstall module_name” command, uninstall the module.
The flask package will be deleted.
In the Python 2.7 version, flask uninstall through pip.
This would be «pip3.6 uninstall —user flask» for Python 3.6.
Following a list of the files that need to be deleted, the command will request your approval. Enter the Enter key after typing «y» to confirm this action.
Note − Installed packages that are directly on the system cannot be removed.
Example
Following example shows how to uninstall python module using pip command −
Output
Following is an output of the above code −
Note − There are a few exceptions, though. Using pip, it is difficult to delete these packages:
Pure distutils packages installed with python setup.py install do not leave any metadata of the files they installed.
The script wrappers that Python setup.py develop install.
All files must be manually deleted, and any other activities performed during installation must be undone. If you are unsure about the complete list of files, you can reinstall it using the —record option and examine the results. To make a list of the installed file, you can use −
Now that you have a list of all the files in the files.txt, you may manually delete them.
Uninstalling a package using conda
The main tool for managing package installations is the conda command. It can −
- Form new environments for conda.
- The Anaconda package index and current Anaconda installation can be queried and searched.
- Installing and updating packages in conda environments that already exist.
Steps involved for uninstalling using conda
Following are the steps to uninstall a package or module using conda command −
To view a list of all the Anaconda virtual environments, open the Anaconda Navigator window and select the Environments menu item from the window’s left side.
Select the Open Terminal menu option from the popup menu list after clicking the green triangle at the end of one Anaconda virtual environment.
It will enter your chosen anaconda virtual environment and start a dos or terminal window.
With the help of «conda uninstall module_name” command, uninstall the module.
To confirm the uninstall outcome, execute the conda list package-name command one more.
Example
Following example shows how to uninstall python module using conda command −
Deleting python modules?
Can you delete python modules? I’ve installed one that I would like to remove, and can’t seem to figure out how.
4 Answers 4
To find where the module is, just do a:
or if it is a package:
If you are using python under windows, the following command is what you need
In some cases, you may have installed different versions of the module. For example, after I had the lxml3.4.4 installed via pip, I also installed lxml3.5.0 using its pre-built binary, and thus, the command listed above only remove the first one. So I need to run it twices
And it got completed uninstalled. See whether it helps.
This has already been asked here.
Go into the «site-packages» directory of your python install and remove the files manually.
Another way using -m flag (especially if Alex Feng’s answer is not working) is:
NOTE: This works only for Windows, and is to be run in the Command Prompt. To see if the module has been uninstalled, simply try to import the module again.
-
The Overflow Blog
Linked
Related
Hot Network Questions
Subscribe to RSS
To subscribe to this RSS feed, copy and paste this URL into your RSS reader.
Site design / logo © 2023 Stack Exchange Inc; user contributions licensed under CC BY-SA . rev 2023.3.3.43278
By clicking “Accept all cookies”, you agree Stack Exchange can store cookies on your device and disclose information in accordance with our Cookie Policy.