Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Getting error 'File "<frozen importlib._bootstrap>", line 968, in _find_and_load' while importing tensorflow

I have Acanonda installed on my system. I installed tensorflow by giving

 pip install tensorflow 

It got successfully installed:

Following was the final trace:

Successfully installed absl-py-0.7.0 astor-0.7.1 gast-0.2.2 grpcio-1.19.0 
keras-applications-1.0.7 keras-preprocessing-1.0.9 markdown-3.0.1 mock-2.0.0 
pbr-5.1.3 protobuf-3.7.0 tensorboard-1.13.0 tensorflow-1.13.1 tensorflow- 
estimator-1.13.0 termcolor-1.1.0

Now I tried to run following script. Nothing fancy, just importing libraries.

import tensorflow as tf
from tensorflow import keras
import numpy as np
import matplotlib.pyplot as plt

On running the script, I got following error:

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-03-02 04:48:32.404215: F tensorflow/python/lib/core/bfloat16.cc:675] 
Check failed: PyBfloat16_Type.tp_base != nullptr

seems to be related to Numpy. Here is the version of my Numpy:'

import numpy
numpy.version.version
1.14.0'

I have some idea of python but am totally new to tensorflow. What am I doing wrong here?

like image 922
Vaibhav Avatar asked Mar 01 '19 23:03

Vaibhav


1 Answers

Try to install numpy v1.16 in a new virtual env:

pip install numpy==1.16 

This should fix the issue.

like image 163
Giorgos Myrianthous Avatar answered Oct 12 '22 10:10

Giorgos Myrianthous