Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Anaconda Python - how to reinstall NumPy

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?

like image 514
Azzam Alsharafi Avatar asked Oct 13 '18 11:10

Azzam Alsharafi


People also ask

How do I reinstall numpy Anaconda?

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.

How do I uninstall numpy and install it again?

Uninstall all the packages and install numpy again. This should solve the problem. Use pip to uninstall. Then install again.

How do I know if numpy is installed on Anaconda?

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.

How to install NumPy in Python using Anaconda?

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.

How to install or uninstall a Python package in conda?

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.

How to install Python packages in Anaconda Navigator?

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.

How to install NumPy in Python on Ubuntu?

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.


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
like image 55
Hagne Avatar answered Oct 19 '22 20:10

Hagne


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

conda remove numpy

And then install it again:

conda install -c anaconda numpy
like image 6
miike3459 Avatar answered Oct 19 '22 18:10

miike3459