代码之家  ›  专栏  ›  技术社区  ›  Hasani

ModuleNotFoundError:没有名为“numpy.core.\u multiarray\u umath”的模块(安装TensorFlow时)

  •  0
  • Hasani  · 技术社区  · 6 年前

    我正在按照本教程安装TensorFlow( https://www.tensorflow.org/install/pip ),但在最后一个命令中:

    python -c "import tensorflow as tf; tf.enable_eager_execution(); print(tf.reduce_sum(tf.random_normal([1000, 1000])))"
    

    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 980, 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-16 12:56:50.178364: F tensorflow/python/lib/core/bfloat16.cc:675] Check failed: PyBfloat16_Type.tp_base != nullptr
    

    我已经安装了 numpy 如你所见:

    pip3 install numpy
    Requirement already satisfied: numpy in c:\programdata\anaconda3\lib\site-packages (1.15.4)
    

    2 回复  |  直到 6 年前
        1
  •  14
  •   Hasani    6 年前

    我升级了 numpy 1.16.1 版本并重试上述命令:

    python -c "import tensorflow as tf; tf.enable_eager_execution(); print(tf.reduce_sum(tf.random_normal([1000, 1000])))"
    

    2019-02-16 13:12:40.611105: I tensorflow/core/platform/cpu_feature_guard.cc:141] Your CPU supports instructions that this TensorFlow binary was not compiled to use: AVX2
    tf.Tensor(-1714.2305, shape=(), dtype=float32)
    
        2
  •  7
  •   Terminator17    6 年前

    升级numpy以解决错误

    pip install numpy --upgrade
    
        3
  •  1
  •   Urmay Shah    6 年前

    我在做爱 1.16.2 1.16.1 这对我很有用。

        4
  •  1
  •   ractiv    5 年前

    您需要强制将numpy升级到最新版本。

    pip install 'numpy==1.16' --force-reinstall
    

    希望这有帮助。

        5
  •  0
  •   aaaakshat    6 年前

    通过运行python 3.x

    python3 -c "import tensorflow as tf; tf.enable_eager_execution(); print(tf.reduce_sum(tf.random_normal([1000, 1000])))"
    
        6
  •  0
  •   Rahul Soshte    6 年前

    我刚刚在Ubuntu 18.10上通过下面的命令将numpy从1.14.0升级到1.17.0。

    没有导入错误。