Skip to content

No module named 'numpy.core._multiarray_umath' #12977

Closed

Description

@bsathyan

I just installed TensorFlow, Keras in anaconda3.

C:\conda create --name neuralnets python=3.7
C:\activate neuralnets

(neuralnets) C:\conda install theano
(neuralnets) C:\conda install mingw libpython
(neuralnets) C:\pip install tensorflow
(neuralnets) C:\pip install keras

Reproducing code example:

Executed this command:

(neuralnets) C:\python -c "from keras import backend; print(backend._BACKEND)"

Got the following error:

Traceback (most recent call last):
  File "C:\Users\Z0035HPP\AppData\Roaming\Python\Python37\site-packages\numpy\core\__init__.py", line 16, in <module>
    from . import multiarray
  File "C:\Users\Z0035HPP\AppData\Roaming\Python\Python37\site-packages\numpy\core\multiarray.py", line 12, in <module>
    from . import overrides
  File "C:\Users\Z0035HPP\AppData\Roaming\Python\Python37\site-packages\numpy\core\overrides.py", line 6, in <module>
    from numpy.core._multiarray_umath import (
ModuleNotFoundError: No module named 'numpy.core._multiarray_umath'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "C:\Users\Z0035HPP\AppData\Local\Continuum\anaconda3\envs\neuralnets\lib\site-packages\keras\__init__.py", line 3, in <module>
    from . import utils
  File "C:\Users\Z0035HPP\AppData\Local\Continuum\anaconda3\envs\neuralnets\lib\site-packages\keras\utils\__init__.py", line 2, in <module>
    from . import np_utils
  File "C:\Users\Z0035HPP\AppData\Local\Continuum\anaconda3\envs\neuralnets\lib\site-packages\keras\utils\np_utils.py", line 6, in <module>
    import numpy as np
  File "C:\Users\Z0035HPP\AppData\Roaming\Python\Python37\site-packages\numpy\__init__.py", line 142, in <module>
    from . import core
  File "C:\Users\Z0035HPP\AppData\Roaming\Python\Python37\site-packages\numpy\core\__init__.py", line 47, in <module>
    raise ImportError(msg)
ImportError:
import numpy as np
<< your code here >>

Error message:

Numpy/Python version information:

Can someone please help? I am new to using keras and tensorflow. I am using it for a class I am taking this semester.

Thanks

Activity

  1. mattip commented on Feb 16, 2019

    @mattip
    Member

    Probably a duplicate of #12957 due to ContinuumIO/anaconda-issues#10628. Copied comment from the duplicate issue:

    There is a difference between the location of the extra support libraries supplied with anaconda and those supplied with stock numpy that you get from pip install. This requires adjustments to the PATH variable. Perhaps the PATH adjustments are failing at import. Does the site-packages\numpy\.libs directory exist and does it contain *.dll files?, If so, can you try to prepend that directory to your PATH before running python:

    rem This fails
    python -c "import numpy"
    
    rem Does this succeed ??? 
    PATH=path\to\site-packages\numpy\.libs;%PATH%
    python -c "import numpy"
    

    But in your case something is different, the path to numpy is missing a path separator: C:\Users\Z0035HPP\AppData\Roaming\Python\Python37\site-packages\numpy\core__init__.py should be C:\Users\Z0035HPP\AppData\Roaming\Python\Python37\site-packages\numpy\core\__init__.py. Is that a copy paste error?

  2. eric-wieser commented on Feb 17, 2019

    @eric-wieser
    Member

    the path to numpy is missing a path separator:

    Just a github formatting issue, wrapping in ``` made that go away

  3. eric-wieser commented on Feb 17, 2019

    @eric-wieser
    Member

    @bsathyan: You've not shown us the full error message. Can you paste the part that comes after the last ImportError too?

  4. bsathyan commented on Feb 17, 2019

    @bsathyan
    Author

    @eric-wieser attached below is the full error thread. Please do let me know if you need anything else.

    Thanks :)

    (neuralnets) C:\Users\Z0035HPP>python -c "from keras import backend; print(backend._BACKEND)"
    Traceback (most recent call last):
      File "C:\Users\Z0035HPP\AppData\Roaming\Python\Python37\site-packages\numpy\core\__init__.py", line 16, in <module>
        from . import multiarray
      File "C:\Users\Z0035HPP\AppData\Roaming\Python\Python37\site-packages\numpy\core\multiarray.py", line 12, in <module>
        from . import overrides
      File "C:\Users\Z0035HPP\AppData\Roaming\Python\Python37\site-packages\numpy\core\overrides.py", line 6, in <module>
        from numpy.core._multiarray_umath import (
    ModuleNotFoundError: No module named 'numpy.core._multiarray_umath'
    
    During handling of the above exception, another exception occurred:
    
    Traceback (most recent call last):
      File "<string>", line 1, in <module>
      File "C:\Users\Z0035HPP\AppData\Local\Continuum\anaconda3\envs\neuralnets\lib\site-packages\keras\__init__.py", line 3, in <module>
        from . import utils
      File "C:\Users\Z0035HPP\AppData\Local\Continuum\anaconda3\envs\neuralnets\lib\site-packages\keras\utils\__init__.py", line 2, in <module>
        from . import np_utils
      File "C:\Users\Z0035HPP\AppData\Local\Continuum\anaconda3\envs\neuralnets\lib\site-packages\keras\utils\np_utils.py", line 6, in <module>
        import numpy as np
      File "C:\Users\Z0035HPP\AppData\Roaming\Python\Python37\site-packages\numpy\__init__.py", line 142, in <module>
        from . import core
      File "C:\Users\Z0035HPP\AppData\Roaming\Python\Python37\site-packages\numpy\core\__init__.py", line 47, in <module>
        raise ImportError(msg)
    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\Z0035HPP\AppData\Local\Continuum\anaconda3\envs\neuralnets\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'
    
  5. NishitHada commented on Feb 19, 2019

    @NishitHada

    I'm also facing the same issue.

    Traceback (most recent call last):
      File "F:\Anaconda\envs\Final_Project\lib\site-packages\numpy\core\__init__.py", line 16, in <module>
        from . import multiarray
      File "F:\Anaconda\envs\Final_Project\lib\site-packages\numpy\core\multiarray.py", line 12, in <module>
        from . import overrides
      File "F:\Anaconda\envs\Final_Project\lib\site-packages\numpy\core\overrides.py", line 9, in <module>
        from numpy.core._multiarray_umath import add_docstring, ndarray
    ImportError: DLL load failed: The specified module could not be found.
    
    During handling of the above exception, another exception occurred:
    
    Traceback (most recent call last):
      File "F:/Python Programs/Final Project/scratch_6.py", line 1, in <module>
        import tensorflow as tf
      File "F:\Anaconda\envs\Final_Project\lib\site-packages\tensorflow\__init__.py", line 24, in <module>
        from tensorflow.python import pywrap_tensorflow  # pylint: disable=unused-import
      File "F:\Anaconda\envs\Final_Project\lib\site-packages\tensorflow\python\__init__.py", line 47, in <module>
        import numpy as np
      File "F:\Anaconda\envs\Final_Project\lib\site-packages\numpy\__init__.py", line 142, in <module>
        from . import core
      File "F:\Anaconda\envs\Final_Project\lib\site-packages\numpy\core\__init__.py", line 47, in <module>
        raise ImportError(msg)
    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 F:\Anaconda\envs\Final_Project\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: DLL load failed: The specified module could not be found.
    
  6. mattip commented on Feb 19, 2019

    @mattip
    Member

    Did the fix suggested in the comment above help? This is a known problem with Anaconda.

  7. NishitHada commented on Feb 20, 2019

    @NishitHada

    No, the path was already correct for me. And yes, this is a problem with anaconda. I used Virtual Environment for the same code and it ran quite well. Something is probably wrong with anaconda it seems.

  8. rgommers commented on Feb 22, 2019

    @rgommers
    Member

    pip install tensorflow picked up numpy from PyPI. Try

    pip uninstall numpy
    conda install numpy
    

    that will probably fix things

  9. mkurovski commented on Feb 26, 2019

    @mkurovski

    Hi,
    I ran into the same issue and followed the advice to uninstall numpy using pip and installing it again with conda - but wasn't successful though.
    However, I was trying to get tensorboard up running with the following ImportError, not exactly the same, but maybe related:

    ModuleNotFoundError: No module named 'numpy.core._multiarray_umath'
    ImportError: numpy.core.multiarray failed to import
    
    The above exception was the direct cause of the following exception:
    
    Traceback (most recent call last):
      File "<frozen importlib._bootstrap>", line 968, in _find_and_load
    SystemError: <class '_frozen_importlib._ModuleLockManager'> returned a result with an error set
    ImportError: numpy.core._multiarray_umath failed to import
    ImportError: numpy.core.umath failed to import
    2019-02-26 21:41:23.671349: F tensorflow/python/lib/core/bfloat16.cc:675] Check failed: PyBfloat16_Type.tp_base != nullptr 
    Abort trap: 6
    
  10. mjahmad commented on Feb 26, 2019

    @mjahmad

    Hi,
    I ran into the same issue and followed the advice to uninstall numpy using pip and installing it again with conda - but wasn't successful though.
    However, I was trying to get tensorboard up running with the following ImportError, not exactly the same, but maybe related:

    ModuleNotFoundError: No module named 'numpy.core._multiarray_umath'
    ImportError: numpy.core.multiarray failed to import
    
    The above exception was the direct cause of the following exception:
    
    Traceback (most recent call last):
      File "<frozen importlib._bootstrap>", line 968, in _find_and_load
    SystemError: <class '_frozen_importlib._ModuleLockManager'> returned a result with an error set
    ImportError: numpy.core._multiarray_umath failed to import
    ImportError: numpy.core.umath failed to import
    2019-02-26 21:41:23.671349: F tensorflow/python/lib/core/bfloat16.cc:675] Check failed: PyBfloat16_Type.tp_base != nullptr 
    Abort trap: 6
    

    Are you running tensorlow using a 3.6 python ? Tensorflow simply does not work with python 3.7.
    I suggest you do this:

    1. Create a new 3.6 python environment, you can do this by running this from terminal, assuming you have anaconda:
      conda create --name tensorflow python=3.6
    2. activate tensorflow:
      activate tensorflow
    3. once activated, trying installing off all your packages.
  11. mkurovski commented on Feb 26, 2019

    @mkurovski

    Hi @mjahmad ,
    Thanks for your reply. Indeed I am running Python 3.6.7 in my environment

  12. mkurovski commented on Feb 26, 2019

    @mkurovski

    OK, I got it now. Just to share in case there might be something useful in for you.
    I uninstalled tensorflow again and only installed version 1.12 of tensorboard:
    pip install tensorboard==1.12
    Works now

  13. kobilinux commented on Feb 27, 2019

    @kobilinux

    hi!
    I succeeded in installing tensorflow in python3.7

    • Failed on first install Message: ModuleNotFoundError: No module named 'numpy.core._multiarray_umath'
    • ModuleNotFoundError:No module named 'numpy.core._multiarray_umath'

    pip uninstall numpy
    pip install numpy
    pip uninstall tensorflow
    pip install tensorflow

    import tensorflow as tf
    success :> thanks

  14. avawda commented on Mar 3, 2019

    @avawda

    pip install tensorflow picked up numpy from PyPI. Try

    pip uninstall numpy
    conda install numpy
    

    that will probably fix things

    This solved my issue, thanks

  15. marisbeautypalace commented on Mar 13, 2019

    @marisbeautypalace

    Hello,

    I have the same issue and tried it with 3.7 and 3.6 enviroment. But there is still the following error:

    from keras.models import Sequential

    Using TensorFlow backend.

    ModuleNotFoundError Traceback (most recent call last)
    ModuleNotFoundError: No module named 'numpy.core._multiarray_umath'

    !pip uninstall numpy
    does'nt work. It runs and runs without any result.

    Thanks!

    Okay, sorry guy's I solved the problem. Maybe it will help you:
    Update to the latest version of numpy :D
    !pip install --upgrade numpy

  16. kobilinux commented on Mar 15, 2019

    @kobilinux
  17. mattip commented on Mar 15, 2019

    @mattip
    Member

    Closing. Hopefully these problems have been solved on the Anaconda side, and some of the suggestions here seem suboptimal. The best solution seems to be

    pip uninstall numpy
    conda install numpy
    
  18. emmmarosewalker commented on Mar 17, 2019

    @emmmarosewalker

    hi!
    I succeeded in installing tensorflow in python3.7

    • Failed on first install Message: ModuleNotFoundError: No module named 'numpy.core._multiarray_umath'
    • ModuleNotFoundError:No module named 'numpy.core._multiarray_umath'

    pip uninstall numpy
    pip install numpy
    pip uninstall tensorflow
    pip install tensorflow

    import tensorflow as tf
    success :> thanks

    this worked for me, thanks

  19. pawan431995 commented on Mar 20, 2019

    @pawan431995

    hello
    i am getting same error while accessing tensorflow as bellow.

    ModuleNotFoundError Traceback (most recent call last)
    ModuleNotFoundError: No module named 'numpy.core._multiarray_umath'

    Solloution :- Update Numpy with latest version

    setp to update numpy as follow

    setp1 open cmd
    setp2 write pip install numpy==leatest version and press Enter
    example pip install numpy==1.16.2

  20. evan-magnusson commented on Apr 17, 2019

    @evan-magnusson

    pip install tensorflow picked up numpy from PyPI. Try

    pip uninstall numpy
    conda install numpy
    

    that will probably fix things

    This worked for me as well. It looks like pip installing tensorflow added a second version of numpy

  21. allanwenzs commented on Apr 30, 2019

    @allanwenzs

    I had the same kind of error, I solved it by creating virtual environment using anaconda, then installing the necessary libraries, it worked.

  22. Jairodub commented on May 19, 2019

    @Jairodub

    I had the same issue and somehow got past it by running

    pip uninstall numpy
    conda install numpy
    pip install numpy
    
  23. 9lash commented on Jun 9, 2019

    @9lash

    Looks like this error is because of multiple packages not installed properly in your specific env. For me, jupyter notebook was not installed in that specific virtual environment. I followed the above comments:

    pip uninstall numpy
    conda install numpy
    pip install numpy 
    

    And then the following fixed it:

    conda install jupyter
    conda install -c conda-forge matplotlib 
    conda install -c anaconda pandas
    

    Now when you open the jupyter notebook from the environment and write the following:

    import matplotlib.pyplot as plt
    import numpy as np
    import pandas as pd
    import tensorflow as tf
    

    there are no errors.

  24. locked as resolved and limited conversation to collaborators on Jun 9, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions