如何安全地“反复卸载 numpy”?为什么这是必要的?

uho*_*hoh 3 python conda

按照http://sfepy.org/doc-devel/installation.html#installing-sfepy 中的指示,我使用以下命令将 SfePy 安装到我的 Python 2.7 anaconda

conda install -c conda-forge sfepy

在那之后,我不能再导入 numpy

>>> import numpy as np
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/Users/david/anaconda2/lib/python2.7/site-packages/numpy/__init__.py", line 142, in <module>
    from . import core
  File "/Users/david/anaconda2/lib/python2.7/site-packages/numpy/core/__init__.py", line 91, in <module>
    raise ImportError(msg.format(path))
ImportError: Something is wrong with the numpy installation. While importing we 
detected an older version of numpy in ['/Users/david/anaconda2/lib/python2.7/site-packages/numpy']. One method of fixing this is to repeatedly uninstall numpy until none is found, then reinstall this version.
Run Code Online (Sandbox Code Playgroud)

我看到消息的最后包含了一些建议:

解决此问题的一种方法是反复卸载 numpy 直到找不到为止,然后重新安装此版本。

问题):

  1. 我究竟如何安全地“反复卸载 numpy”?这个答案提到了,conda remove --force但这对我来说听起来很可怕。
  2. 一旦“没有找到”会conda install -c conda-forge sfepy再次重新安装一个好的 numpy?
  3. 为什么会发生这种情况?它可能反映了一些潜在的严重问题,还是只是“其中之一”,我应该“反复卸载 numpy”并继续我的生活?

Jam*_*mes 5

当您使用 pip 安装时,通常会反复卸载 numpy。因为您使用的是 Conda,所以尝试conda uninstall numpy删除 numpy 和任何依赖于 numpy 的包(以及任何依赖于这些的包等)。

通常,这意味着您将破坏您的环境。使用 Conda 的全部意义在于创建新的、隔离的环境,这样您就不必担心会遇到什么:包冲突。

您应该采取的步骤是:

  1. 卸载 Anaconda,看起来您可能已经破坏了您的基本安装。另外,下车 PYTHON 2.7!

  2. 重新安装 Anaconda,最好使用 Python 3.6 或更高版本。

  3. 使用 conda 创建一个隔离的环境供您工作。 conda create -n finite python=3.6 sfepy numpy pandas ipython

  4. 激活并使用该环境在有限分析中完成您的工作。 conda activate finite