Anaconda Python-如何重新安装NumPy

时间:2018-10-13 11:58:57

标签: python numpy scikit-learn anaconda conda

我在Visual Studio Code中使用Anaconda 5.3.0的Python解释器。尝试导入sklearn时出现错误:

Traceback (most recent call last):
  File "c:\Users\azzam\machinelearning.py", line 1, in <module>
    import sklearn
  File "C:\Anaconda3\lib\site-packages\sklearn\__init__.py", line 134, in <module>
    from .base import clone
  File "C:\Anaconda3\lib\site-packages\sklearn\base.py", line 10, in <module>
    import numpy as np
  File "C:\Anaconda3\lib\site-packages\numpy\__init__.py", line 142, in <module>
    from . import add_newdocs
  File "C:\Anaconda3\lib\site-packages\numpy\add_newdocs.py", line 13, in <module>
    from numpy.lib import add_newdoc
  File "C:\Anaconda3\lib\site-packages\numpy\lib\__init__.py", line 8, in <module>
    from .type_check import *
  File "C:\Anaconda3\lib\site-packages\numpy\lib\type_check.py", line 11, in <module>
    import numpy.core.numeric as _nx
  File "C:\Anaconda3\lib\site-packages\numpy\core\__init__.py", line 26, in <module>
    raise ImportError(msg)
ImportError:
Importing the multiarray numpy extension module failed.  Most
likely you are trying to import a failed build of numpy.
If you're working with a numpy git repo, try `git clean -xdf` (removes all
files not under version control).  Otherwise reinstall numpy.

Original error was: DLL load failed: The specified module could not be found.

看来我需要“重新安装” NumPy。我在网上搜索,但是找不到“重新安装”的方法。只有“安装”方式,以及当我使用时

conda install numpy

在Anaconda提示中,我得到:

Solving environment: done

# All requested packages already installed.

如果我尝试删除NumPy再次安装,它将删除所有内容,而不仅仅是NumPy。那么,我真的需要“重新安装” NumPy才能导入sklearn吗? 如果可以,如何“重新安装” NumPy?

2 个答案:

答案 0 :(得分:10)

如何重新安装软件包取决于conda版本。

newer versions(> = 4.6):

conda install numpy --force-reinstall

旧版本(<4.6):

conda install numpy --force

答案 1 :(得分:0)

您很可能必须卸载NumPy并重新安装。

conda remove numpy

然后重新安装:

conda install -c anaconda numpy