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?
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.
Uninstall all the packages and install numpy again. This should solve the problem. Use pip to uninstall. Then install again.
Make sure you are using the Anaconda prompt, as the conda command only works in an Anaconda environment, and type conda list numpy . The result will show the version of numpy and associated packages.
You can easily install NumPy in Python using Anaconda with the following code. If you want to learn Python then I will highly recommend you to read This Book. How to install NumPy in Python using Anaconda? Write the given code in Anaconda Prompt and press enter to install NumPy.
Run the command conda install package-name to install the python package like below. After you successfully install the python package, you can run the command conda list package-name to verify that it has been installed. To uninstall a python package, you can run the command conda uninstall package-name.
1.2 Install Python Packages From Anaconda Navigator Python Packages List Window Steps. To install one python package, you can select the Not installed menu item from the drop-down list, then input the search keyword such as pandas in the Search Packages search box and click enter key.
Use the pip3 command in order to install NumPy. The usage of pip3 command is to specify your system that you are working on a Python 3 version. The below image helps you in the installation process: In case of Ubuntu, you will notice that Python is already installed but pip isn’t.
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With