Sean
Sean

Reputation: 3450

After installing Jupyter Notebook NumPy and TensorFlow are not working

I was using Jupyter Notebook to do some studying today and noticed that I couldn't import Tensorflow or Keras. It was strange because until yesterday it was working fine. Anyway, I looked online and some people recommended I install Jupyter again using conda install jupyter notebook. I did exactly that and now I can't even import Tensorflow or NumPy. Not to mention whenever I try to open Jupyter that doesn't work either. I see a command prompt flash briefly and then nothing happens.

When I try to import either, I get this error:

---------------------------------------------------------------------------
ModuleNotFoundError                       Traceback (most recent call last)
~\Anaconda3\lib\site-packages\numpy\core\__init__.py in <module>
     39 try:
---> 40     from . import multiarray
     41 except ImportError as exc:

~\Anaconda3\lib\site-packages\numpy\core\multiarray.py in <module>
     11
---> 12 from . import overrides
     13 from . import _multiarray_umath

~\Anaconda3\lib\site-packages\numpy\core\overrides.py in <module>
      5
----> 6 from numpy.core._multiarray_umath import (
      7     add_docstring, implement_array_function, _get_implementing_args)

ModuleNotFoundError: No module named 'numpy.core._multiarray_umath'

During handling of the above exception, another exception occurred:

ImportError                               Traceback (most recent call last)
<ipython-input-1-0aa0b027fcb6> in <module>
----> 1 import numpy as np

~\Anaconda3\lib\site-packages\numpy\__init__.py in <module>
    140     from . import _distributor_init
    141
--> 142     from . import core
    143     from .core import *
    144     from . import compat

~\Anaconda3\lib\site-packages\numpy\core\__init__.py in <module>
     69 Original error was: %s
     70 """ % (sys.executable, exc)
---> 71     raise ImportError(msg)
     72 finally:
     73     for envkey in env_added:

ImportError:

IMPORTANT: PLEASE READ THIS FOR ADVICE ON HOW TO SOLVE THIS ISSUE!

Importing the multiarray numpy extension module failed.  Most
likely you are trying to import a failed build of numpy.
Here is how to proceed:
- If you're working with a numpy git repository, try `git clean -xdf`
  (removes all files not under version control) and rebuild numpy.
- If you are simply trying to use the numpy version that you have installed:
  your installation is broken - please reinstall numpy.
- If you have already reinstalled and that did not fix the problem, then:
  1. Check that you are using the Python you expect (you're using 
C:\Users\seant\Anaconda3\python.exe),
     and that you have no directories in your PATH or PYTHONPATH that can
     interfere with the Python and numpy versions you're trying to use.
  2. If (1) looks fine, you can open a new issue at
     https://github.com/numpy/numpy/issues.  Please include details on:
     - how you installed Python
     - how you installed numpy
     - your operating system
     - whether or not you have multiple versions of Python installed
     - if you built from source, your compiler versions and ideally a build log

     Note: this error has many possible causes, so please don't comment on
     an existing issue about this - open a new one instead.

Original error was: No module named 'numpy.core._multiarray_umath'

I tried reinstalling NumPy, but that didn't solve the issue. I installed Python and NumPy via installing Anaconda, and my operating system is Windows 10. My path variable looked normal as well and everything was working until now. Does anyone know how I can proceed to fix this issue?

Upvotes: 2

Views: 917

Answers (2)

Sean
Sean

Reputation: 3450

In my case I just spent around an hour uninstalling everything Python-related (Python, Anaconda, etc.) and completely installing everything from scratch again. It was a bit of a pain but I didn't know what else to do without having to dive too deeply into the issue.

Upvotes: 0

Tungata
Tungata

Reputation: 685

Go to your terminal and locate the environment where you have Numpy and the other modules installed. If your'e using virtualenvwrapper you can run: lsvirtualenv a list of your virtual envs you have will be displayed.

Then type workon virtualenv1 (replace with name of displayed virtual env) and check for your installed modules e.g after selecting the virtual env you can then type python and get into the shell. Then you can do import numpy etc to check if the modules youre looking for exist in that virtualenv. When you find them you can then exit out of the shell and do a pip install jupyter to install jupyter notebooks on the virtual env with the modules you need. To avoid meeting such problems in future you should make sure you maintain virtual environments in your machine with the modules that your're interested to work with as per virtual env. Virtualenvwrapper is a great tool that abstracts away most of the common pitfalls found with working with virtual envs. More info in managing and creating virtual envs can be found here.

Upvotes: 1

Related Questions