Python 如何在 OSX 上卸载 pip?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/21012597/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-18 21:47:35  来源:igfitidea点击:

How to uninstall pip on OSX?

pythonmacospip

提问by Setsuna

I ran the following commands:

我运行了以下命令:

easy_install pip
sudo pip install setuptools --no-use-wheel --upgrade

How do I reverse the two commands to get my python back to its original state in OSX? (removing pip as part of it)

如何反转这两个命令以使我的 python 在 OSX 中恢复到其原始状态?(删除 pip 作为其中的一部分)

采纳答案by nacho_dh

The first thing you should try is:

您应该尝试的第一件事是:

sudo pip uninstall pip

On many environments that doesn't work. So given the lack of info on that problem, I ended up removing pip manually from /usr/local/bin.

在许多不起作用的环境中。因此,鉴于缺乏有关该问题的信息,我最终从 /usr/local/bin 中手动删除了 pip。

回答by aralar

In order to completely remove pip, I believe you have to delete its files from all Python versions on your computer. For me, they are here:

为了彻底删除 pip,我相信您必须从计算机上的所有 Python 版本中删除其文件。对我来说,他们在这里:

cd /Library/Frameworks/Python.framework/Versions/Current/bin/
cd /Library/Frameworks/Python.framework/Versions/3.3/bin/

You may need to remove the files or the directories located at these file-paths (and more, depending on the number of versions of Python you have installed).

您可能需要删除位于这些文件路径中的文件或目录(以及更多,取决于您安装的 Python 版本数)。

Edit: to find all versions of pip on your machine, use: find / -name pip 2>/dev/null, which starts at its highest level (hence the /) and hides all error messages (that's what 2>/dev/nulldoes). This is my output:

编辑: 要在您的机器上查找所有版本的 pip,请使用: find / -name pip 2>/dev/null,它从最高级别开始(因此是/)并隐藏所有错误消息(这就是这样2>/dev/null做的)。这是我的输出:

$ find / -name pip 2>/dev/null
/Library/Frameworks/Python.framework/Versions/2.7/bin/pip
/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/pip
/Library/Frameworks/Python.framework/Versions/3.3/bin/pip
/Library/Frameworks/Python.framework/Versions/3.3/lib/python3.3/site-packages/pip
/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/pip
/Library/Frameworks/Python.framework/Versions/7.1/bin/pip
/Library/Frameworks/Python.framework/Versions/7.1/lib/python2.7/site-packages/pip-1.4.1-py2.7.egg/pip

回答by srk

In my case I ran the following command and it worked (not that I was expecting it to):

在我的情况下,我运行了以下命令并且它起作用了(不是我期望的):

sudo pip uninstall pip

Which resulted in:

这导致:

Uninstalling pip-6.1.1:
  /Library/Python/2.7/site-packages/pip-6.1.1.dist-info/DESCRIPTION.rst
  /Library/Python/2.7/site-packages/pip-6.1.1.dist-info/METADATA
  /Library/Python/2.7/site-packages/pip-6.1.1.dist-info/RECORD
  <and all the other stuff>
  ...

  /usr/local/bin/pip
  /usr/local/bin/pip2
  /usr/local/bin/pip2.7
Proceed (y/n)? y
  Successfully uninstalled pip-6.1.1

回答by Pushp Raj Saurabh

Delete all the pip related files from /usr/local/bin. It does the magic.

从 /usr/local/bin 中删除所有 pip 相关文件。它发挥了神奇的作用。

回答by t0r0X

Aditionally to the answer from @srk, you should uninstall package setuptools:

除了@srk 的回答之外,您应该卸载 package setuptools

python -m pip uninstall pip setuptools

If you want to uninstall all other packages first, this answer has some hints: https://stackoverflow.com/a/11250821/265954

如果你想先卸载所有其他包,这个答案有一些提示:https: //stackoverflow.com/a/11250821/265954

Note: before you use the commands from that answer, please carefully read the comments about side effects and how to avoid uninstalling pipand setuptoolstoo early. E.g. pip freeze | grep -v "^-e" | grep -v "^(setuptools|pip)" | xargs pip uninstall -y

注意:在使用该答案中的命令之前,请仔细阅读有关副作用以及如何避免卸载pipsetuptools过早卸载的评论。例如pip freeze | grep -v "^-e" | grep -v "^(setuptools|pip)" | xargs pip uninstall -y