Python 无法卸载“numpy”

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/50978670/
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-19 19:40:39  来源:igfitidea点击:

Cannot uninstall 'numpy'

pythonmacosnumpypip

提问by Sara Couti?o De León

I've been trying to install astropy and at the end of the installation I get this message:

我一直在尝试安装 astropy,在安装结束时我收到以下消息:

Cannot uninstall 'numpy'. It is a distutils installed project and thus we cannot accurately determine which files belong to it which would lead to only a partial uninstall.

无法卸载“numpy”。这是一个 distutils 安装的项目,因此我们无法准确确定哪些文件属于它,这只会导致部分卸载。

I have tried: pip uninstall numpyand then I get the same message. I have Python 2.7.10 in a macOS High Sierra version 13.10.5

我试过了:pip uninstall numpy然后我得到了同样的消息。我在 macOS High Sierra 版本 13.10.5 中有 Python 2.7.10

(I am very new at Python, and I looked for answers before asking but nothing worked).

(我对 Python 非常陌生,我在问之前寻找了答案,但没有任何效果)。

采纳答案by abarnert

This doesn't directly answer your question, but that's because you're asking the wrong question.

这并不能直接回答您的问题,但那是因为您问错了问题。

Astropy requires Python 3.5 or 3.6. Trying to get it working with Apple's pre-installed Python 2.7 is a waste of time. You mightbe able to get an old version working this way, but not by using the installation instructions on astropy.org, and it won't be supported even if you do.

Astropy 需要 Python 3.5 或 3.6。试图让它与 Apple 预装的 Python 2.7 一起工作是浪费时间。您可能能够以这种方式运行旧版本,但不能使用 astropy.org 上的安装说明,即使您这样做也不会得到支持。



The easy solution is to just Install the latest Anaconda 5.x with Python 3.6, because it comes with Astropy built in.

简单的解决方案是使用 Python 3.6 安装最新的 Anaconda 5.x,因为它内置了 Astropy



The almost-as-easy solution is to install Python 3.6 from either a python.org binary installer, or Homebrew, and then use pip3or, better, python3 -m pipto install everything, as explained on the Astropy install page.

几乎同样简单的解决方案是从 python.org 二进制安装程序或 Homebrew 安装 Python 3.6,然后使用pip3或者更好python3 -m pip地安装所有内容,如 Astropy 安装页面所述



Either way, before doing anything else, you want to get back to a clean slate. In particular, you do not want pip, or any other scripts, attached to Apple's Python 2.7; they will only cause confusion. Assuming you can't reinstall macOS from scratch, the best way to do this is:

无论哪种方式,在做任何其他事情之前,你都想回到一个干净的状态。特别是,您不希望pip附加到 Apple 的 Python 2.7 或任何其他脚本;它们只会引起混乱。假设您无法从头开始重新安装 macOS,最好的方法是:

  • Look in /Library/Python/2.7/site-packagesand delete everything there except for READMEand Extras.pth.
  • Look in /usr/local/binfor symlinks to anything in that site-packages. (If you don't know much about using Unix, try this command: ls -l /usr/local/bin | grep 2.7.) You'll probably have pipand pip2.7here, and probably nothing else. But whatever you have here, delete it.
  • 查看/Library/Python/2.7/site-packages并删除除README和之外的所有内容Extras.pth
  • 寻找其中/usr/local/bin任何内容的符号链接site-packages。(如果您对使用 Unix 不太了解,请尝试以下命令:ls -l /usr/local/bin | grep 2.7。)您可能拥有pippip2.7在这里,可能没有别的。但不管你在这里有什么,删除它。

Now, when you install Python 3.6, the only thing named pipanywhere will be that Python 3.6's pip. You still want to use pip3or python3 -m pip, but if you screw up and type pipby accident, it won't break anything.

现在,当您安装 Python 3.6 时,唯一命名的pip地方将是 Python 3.6 的pip. 你仍然想使用pip3or python3 -m pip,但如果你pip不小心打错了字,它不会破坏任何东西。



Also, you should strongly consider using a virtual environment. See the Python Packaging Authority's User Guide(or the Anaconda docs, if you went that way) for more on this.

此外,您应该强烈考虑使用虚拟环境。有关这方面的更多信息,请参阅 Python Packaging Authority 的用户指南(或 Anaconda 文档,如果您这样做的话)。

回答by Wuzhou Zhang

One simple solution I found:

我找到了一个简单的解决方案:

sudo -H pip install astropy --ignore-installed numpy

回答by InterestingGuy

I also had this issue and couldn't get around it in a clean way, but this is what I did:

我也遇到了这个问题,无法以干净的方式解决它,但这就是我所做的:

Inside the Lib folder search "numpy" for an egg_info file (eg. numpy-1.11.0.dev0_2329eae.egg-info).

在 Lib 文件夹中搜索“numpy”以获取 egg_info 文件(例如 numpy-1.11.0.dev0_2329eae.egg-info)。

In my case, this is what Pip was looking at to determine if a current version already exists. I deleted it, then ran normal

就我而言,这就是 Pip 正在查看的内容,以确定当前版本是否已经存在。我删除了它,然后运行正常

pip install numpy

and installed the newest version.

并安装了最新版本。

I don't recommend this because I don't understand what it's doing under the hood and it doesn't properly uninstall the old version which could be a recipe for trouble down the line, but if you're desperate like I was then maybe this is a solution for you.

我不推荐这个,因为我不明白它在幕后做了什么,它没有正确卸载旧版本,这可能是一个麻烦的秘诀,但如果你像我一样绝望,那么也许这是您的解决方案。