ellibria
ellibria

Reputation: 61

python Tensorflow ImportError

Error in the import statement for Tensorflow:

 import tensorflow as tf 
Traceback (most recent call last):   File
 "/home/user/anaconda3/lib/python3.6/site-packages/tensorflow/python/pywrap_tensorflow.py",
 line 41, in <module>
     from tensorflow.python.pywrap_tensorflow_internal import *   File "/home/user/anaconda3/lib/python3.6/site-packages/tensorflow/python/pywrap_tensorflow_internal.py",
 line 28, in <module>
     _pywrap_tensorflow_internal = swig_import_helper()   File "/home/user/anaconda3/lib/python3.6/site-packages/tensorflow/python/pywrap_tensorflow_internal.py",
 line 24, in swig_import_helper
     _mod = imp.load_module('_pywrap_tensorflow_internal', fp, pathname, description)   File
 "/home/user/anaconda3/lib/python3.6/imp.py", line 243, in load_module
     return load_dynamic(name, filename, file)   File "/home/user/anaconda3/lib/python3.6/imp.py", line 343, in load_dynamic
     return _load(spec) ImportError: libcusolver.so.8.0: cannot open shared object file: No such file or directory

 During handling of the above exception, another exception occurred:
 Traceback (most recent call last):   File "<stdin>", line 1, in
 <module>   File
 "/home/user/anaconda3/lib/python3.6/site-packages/tensorflow/__init__.py",
 line 24, in <module>
     from tensorflow.python import *   File "/home/user/anaconda3/lib/python3.6/site-packages/tensorflow/python/__init__.py",
 line 49, in <module>
     from tensorflow.python import pywrap_tensorflow   File "/home/user/anaconda3/lib/python3.6/site-packages/tensorflow/python/pywrap_tensorflow.py",
 line 52, in <module>
     raise ImportError(msg) ImportError: Traceback (most recent call last):   File
 "/home/user/anaconda3/lib/python3.6/site-packages/tensorflow/python/pywrap_tensorflow.py",
 line 41, in <module>
     from tensorflow.python.pywrap_tensorflow_internal import *   File "/home/user/anaconda3/lib/python3.6/site-packages/tensorflow/python/pywrap_tensorflow_internal.py",
 line 28, in <module>
     _pywrap_tensorflow_internal = swig_import_helper()   File "/home/user/anaconda3/lib/python3.6/site-packages/tensorflow/python/pywrap_tensorflow_internal.py",
 line 24, in swig_import_helper
     _mod = imp.load_module('_pywrap_tensorflow_internal', fp, pathname, description)   File
 "/home/user/anaconda3/lib/python3.6/imp.py", line 243, in load_module
     return load_dynamic(name, filename, file)   File "/home/user/anaconda3/lib/python3.6/imp.py", line 343, in load_dynamic
     return _load(spec) ImportError: libcusolver.so.8.0: cannot open shared object file: No such file or directory

Failed to load the native TensorFlow runtime.

See the tensorflow documentation for some common reasons and solutions.

Upvotes: 6

Views: 3496

Answers (2)

gamzeakkurt
gamzeakkurt

Reputation: 41

Before importing TensorFlow, you need to install TensorFlow on Python 3.6. Firstly, I assumed that you use the Windows operating system because you did not explain any information about your computer. Open the Anaconda prompt, install TensorFlow with this command:

pip install tensorflow==2.0

If everything installs successfully, you can import the TensorFlow library in Python.

import tensorflow as tf 

Upvotes: 0

Charles Cao
Charles Cao

Reputation: 116

You could try that:

  1. Confirm the python interpreter path, is anaconda or system python?

  2. export python library export PYTHONPATH=xxxxx:$PYTHONPATH to solve some lib couldn't find before execute a python script in terminal.

If you following two step, above troubles could be solved.

Upvotes: 1

Related Questions