37

I am trying to run jupyter notebook and getting following error. I am using Win 7 with anaconda python 3.7.

ImportError: Something is wrong with the numpy installation. While importing we detected an older version of numpy in ['c:\users\paperspace\anaconda3\envs\tensorflow10\lib\site-packages\numpy']. One method of fixing this is to repeatedly uninstall numpy until none is found, then reinstall this version.

I have followed the steps mentioned in the error but still not working.

Evan Carroll
  • 78,363
  • 46
  • 261
  • 468
Nishant
  • 613
  • 3
  • 9
  • 21
  • Have you tried removing the complete environment tensorflow10 and creating it again? Are you using the command line or something else to access conda? – p13rr0m Feb 15 '19 at 20:19
  • As @pierrom mentioned, removing the Anaconda env and then creating it again was a work around for me which worked. – Shubham Panchal Feb 16 '19 at 03:20
  • @pierrom I did not try removing env. I will create a new environment and tensorflow11 and try again. I am using the command line to access anaconda. – Nishant Feb 20 '19 at 13:19
  • I did try creating a new environment but still getting the same error. :( – Nishant Feb 20 '19 at 14:45
  • Can you maybe edit your question and show how you set up the environment and how you install the packages. I'm no windows user so I don't no what is happening here, but maybe I can give you some advice that could still help you. – p13rr0m Feb 20 '19 at 22:44

11 Answers11

23

Run

pip3 uninstall numpy

until you receive a message stating no files available with numpy to uninstall and then you can freshly install numpy using

pip install numpy

and that will fix the issue.

Sundeep Pidugu
  • 2,377
  • 2
  • 21
  • 43
19

Remove the folder numpy and reinstall numpy. work for me. Code below

rm -rf ~/.local/lib/python3.6/site-packages/numpy
pip install numpy
Community
  • 1
  • 1
anthony .bm
  • 191
  • 1
  • 5
  • 1
    Code-only answers are discouraged. Please click on [edit] and add some words summarising how your code addresses the question, or perhaps explain how your answer differs from the previous answer/answers. [From Review](https://stackoverflow.com/review/low-quality-posts/23873177) – Nick Aug 24 '19 at 04:40
  • manually removing the directory and pip-installing worked for me – pcko1 Nov 25 '19 at 09:56
  • manual remove works for me too. uninstall then reinstall only does not make the issue gone. – fsevenm Aug 09 '20 at 12:12
10

I was getting the error when I was trying to use Keras. This can be fixed by removing the numpy package continuously by running pip3 uninstall numpy. And checking the successful un-installation by opening a python terminal and importing numpy package.

KK2491
  • 451
  • 1
  • 8
  • 25
  • 1
    Same here. I use Anaconda and installed tensorflow and then keras, and ended up with two versions of numpy 1.16.2 and 1.14.5. How can I fix this error under Anaconda? I am afraid pip uninstall would break everything – Paul Beloff Mar 29 '19 at 08:40
  • How did you install the packages inside conda environment? – KK2491 Mar 29 '19 at 08:53
  • I was getting AVX errors and installed a tensorflow binary from this thread https://stackoverflow.com/a/50073238/3224242 then installed keras as: conda install keras – Paul Beloff Mar 29 '19 at 09:15
  • I got the `Skipping numpy as it is not installed.` message after repeated uninstalls, but when I try to run a --help command for my keras package, I get this error: `ImportError: Something is wrong with the numpy installation. While importing we detected an older version of numpy in ['/anaconda3/lib/python3.6/site-packages/numpy']. One method of fixing this is to repeatedly uninstall numpy until none is found, then reinstall this version.` What am I missing? – WhooNo Jul 15 '21 at 22:16
4

This Means a Duplicated. Try pip uninstall numpy or pip3 uninstall numpy then sudo apt-get install python3-numpy

FOR (DEBIAN DIST)

钟智强
  • 459
  • 6
  • 17
3

Use conda update --all

This works.

2

From what I understand, you have possibly used multiple package download managers, possibly to install something other than numpy but that has a dependency on numpy. Since you are using anaconda environment, it is a good practice to try to not to use other package managers such as pip in the same environment. When that happens, the problem is that pip adds the lib file as the path for the library and so, the system points to that numpy installation.(or in our case, does not know which one to choose)

So, use the equivalent of :

pip show <name of the package, i.e numpy> 
conda list <name of the package, i.e numpy> 

etc. Use the above to check which versions of these libraries you have on your system. Then, use the equivalent commands to remove all these versions. Be careful about the dependencies!

pip uninstall <name of the package, i.e numpy> 
conda uninstall <name of the package, i.e numpy> 

etc.

Next, use the anaconda environment to download the version of numpy that you require. The dependencies are probably going to get jumbled up.

In the future, try to create a new anaconda environment if you see dependency version conflicts instead of using some other package managers to download.

Cheers! I hope that helps.

Shalini Maiti
  • 346
  • 2
  • 5
1

per https://github.com/numpy/numpy/issues/12976, tried conda update -c defaults numpy and it worked. YMMV...

Hertzel Guinness
  • 5,912
  • 3
  • 38
  • 43
0

Besides all the other answers, you may try something like

yum erase numpy

if you intalled some python library using yum install or apt-get install

JasonWayne
  • 1,724
  • 1
  • 19
  • 16
0

Apparently, multiple versions of numpy is installed on the computer in the same python virtual environment. This is strange and never happened with any other packages. Uninstall all the packages and install numpy again. This should solve the problem.

Use pip to uninstall.

pip3 uninstall numpy 
# or
python3 -m pip uninstall numpy

Then install again. Preferably with the exact version number.

pip3 install numpy==1.18.4

I had to uninstall numpy thrice. Until I got the message WARNING: Skipping numpy as it is not installed.

Trect
  • 2,759
  • 2
  • 30
  • 35
0

Your issue maybe similar to mine below.

How to reproduce it

  1. Started a virtual environment named "jupyter_ve" with numpy=1.21.0 where I launched jupyter.
  2. Opened a notebook using a virtual environment named "project_ve" with numpy=1.20.0 where I launched my notebook kernel using "project_ve"
  3. In Notebook import fails on from numba import njit giving errors install numpy 1.20.0 or lower

Solution

Make sure you install numpy version in the virtual environment you used to start the jupyter.

In my case above I had to install / downgrade numpy in the virtual envrionment where I launched jupyter from. It doesn't matter that I had installed notebook virtual environment kernel.

Carlos Ferreira
  • 1,980
  • 2
  • 14
  • 18
-2

For me it was about the consoles used.

My cygwin terminal - NOPE, dos - NOPE, but console opened from Anaconda or Spyder etc... all commands (pip install etc) worked.

jkdev
  • 11,360
  • 15
  • 54
  • 77