I am using Anaconda 5.3.0's Python interpreter in Visual Studio Code. When I try to import sklearn I get an error:

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. 

It looks like that I need to "reinstall" NumPy. I searched on the web, but I didn't find a way to "reinstall". There is only how to "install", and when I use

conda install numpy 

in Anaconda Prompt I get:

Solving environment: done # All requested packages already installed. 

And if I tried to remove NumPy to install it again, it will remove everything, not just NumPy. So do I really need to "reinstall" NumPy to be able to import sklearn? And if I do, how do I "reinstall" NumPy?

5

2 Answers

How to reinstall a package depends on the conda version.

newer versions (>= 4.6):

conda install numpy --force-reinstall 

older versions (< 4.6):

conda install numpy --force 

You will most likely have to uninstall NumPy and reinstall it.

conda remove numpy 

And then install it again:

conda install -c anaconda numpy 
5

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy