1
votes

In command-line, everything seems fine. But when I am importing tensorflow in sublime text or spyder it gives the following error -

import tensorflow as tf

Traceback (most recent call last): File "/usr/local/lib/python3.6/dist-packages/tensorflow/python/pywrap_tensorflow.py", line 58, in from tensorflow.python.pywrap_tensorflow_internal import * File "/usr/local/lib/python3.6/dist-packages/tensorflow/python/pywrap_tensorflow_internal.py", line 28, in _pywrap_tensorflow_internal = swig_import_helper() File "/usr/local/lib/python3.6/dist-packages/tensorflow/python/pywrap_tensorflow_internal.py", line 24, in swig_import_helper _mod = imp.load_module('_pywrap_tensorflow_internal', fp, pathname, description) File "/usr/lib/python3.6/imp.py", line 243, in load_module return load_dynamic(name, filename, file) File "/usr/lib/python3.6/imp.py", line 343, in load_dynamic return _load(spec) ImportError: libcublas.so.9.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 "/home/himanshu/Desktop/iii.py", line 1, in import tensorflow as tf File "/usr/local/lib/python3.6/dist-packages/tensorflow/init.py", line 24, in from tensorflow.python import pywrap_tensorflow # pylint: disable=unused-import File "/usr/local/lib/python3.6/dist-packages/tensorflow/python/init.py", line 49, in from tensorflow.python import pywrap_tensorflow File "/usr/local/lib/python3.6/dist-packages/tensorflow/python/pywrap_tensorflow.py", line 74, in raise ImportError(msg) ImportError: Traceback (most recent call last): File "/usr/local/lib/python3.6/dist-packages/tensorflow/python/pywrap_tensorflow.py", line 58, in from tensorflow.python.pywrap_tensorflow_internal import * File "/usr/local/lib/python3.6/dist-packages/tensorflow/python/pywrap_tensorflow_internal.py", line 28, in _pywrap_tensorflow_internal = swig_import_helper() File "/usr/local/lib/python3.6/dist-packages/tensorflow/python/pywrap_tensorflow_internal.py", line 24, in swig_import_helper _mod = imp.load_module('_pywrap_tensorflow_internal', fp, pathname, description) File "/usr/lib/python3.6/imp.py", line 243, in load_module return load_dynamic(name, filename, file) File "/usr/lib/python3.6/imp.py", line 343, in load_dynamic return _load(spec) ImportError: libcublas.so.9.0: cannot open shared object file: No such file or directory

When I am importing keras

import keras

following is the error

Using TensorFlow backend. Traceback (most recent call last): File "/usr/local/lib/python3.6/dist-packages/tensorflow/python/pywrap_tensorflow.py", line 58, in from tensorflow.python.pywrap_tensorflow_internal import * File "/usr/local/lib/python3.6/dist-packages/tensorflow/python/pywrap_tensorflow_internal.py", line 28, in _pywrap_tensorflow_internal = swig_import_helper() File "/usr/local/lib/python3.6/dist-packages/tensorflow/python/pywrap_tensorflow_internal.py", line 24, in swig_import_helper _mod = imp.load_module('_pywrap_tensorflow_internal', fp, pathname, description) File "/usr/lib/python3.6/imp.py", line 243, in load_module return load_dynamic(name, filename, file) File "/usr/lib/python3.6/imp.py", line 343, in load_dynamic return _load(spec) ImportError: libcublas.so.9.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 "/home/himanshu/Desktop/iii.py", line 1, in import keras File "/usr/local/lib/python3.6/dist-packages/keras/init.py", line 3, in from . import utils File "/usr/local/lib/python3.6/dist-packages/keras/utils/init.py", line 6, in from . import conv_utils File "/usr/local/lib/python3.6/dist-packages/keras/utils/conv_utils.py", line 9, in from .. import backend as K File "/usr/local/lib/python3.6/dist-packages/keras/backend/init.py", line 89, in from .tensorflow_backend import * File "/usr/local/lib/python3.6/dist-packages/keras/backend/tensorflow_backend.py", line 5, in import tensorflow as tf File "/usr/local/lib/python3.6/dist-packages/tensorflow/init.py", line 24, in from tensorflow.python import pywrap_tensorflow # pylint: disable=unused-import File "/usr/local/lib/python3.6/dist-packages/tensorflow/python/init.py", line 49, in from tensorflow.python import pywrap_tensorflow File "/usr/local/lib/python3.6/dist-packages/tensorflow/python/pywrap_tensorflow.py", line 74, in raise ImportError(msg) ImportError: Traceback (most recent call last): File "/usr/local/lib/python3.6/dist-packages/tensorflow/python/pywrap_tensorflow.py", line 58, in from tensorflow.python.pywrap_tensorflow_internal import * File "/usr/local/lib/python3.6/dist-packages/tensorflow/python/pywrap_tensorflow_internal.py", line 28, in _pywrap_tensorflow_internal = swig_import_helper() File "/usr/local/lib/python3.6/dist-packages/tensorflow/python/pywrap_tensorflow_internal.py", line 24, in swig_import_helper _mod = imp.load_module('_pywrap_tensorflow_internal', fp, pathname, description) File "/usr/lib/python3.6/imp.py", line 243, in load_module return load_dynamic(name, filename, file) File "/usr/lib/python3.6/imp.py", line 343, in load_dynamic return _load(spec) ImportError: libcublas.so.9.0: cannot open shared object file: No such file or directory

Failed to load the native TensorFlow runtime.

Note - I am using pip for my python packages and not conda

1
Seems like your IDEs are using a different environment than your command line. Can you do a import sys; print(sys.executable) both from the command line python and within the python of Spyder or Sublime?sh37211
It is the same - "/usr/bin/python3"final Plankton
Oh, I see. It can't find the cublas library. This suggests a difference in the lib paths. Can you run import os; print(os.environ['LD_LIBRARY_PATH']), again in your various versions of python?sh37211
This is the output when run on console - usr/local/cuda/lib64:final Plankton
This is the output from Spyder - Traceback (most recent call last): File "<ipython-input-2-5281a39f963c>", line 1, in <module> import os; print(os.environ['LD_LIBRARY_PATH']) File "/home/himanshu/venv/deeplearning_keras/lib/python3.6/os.py", line 669, in getitem raise KeyError(key) from None KeyError: 'LD_LIBRARY_PATH']final Plankton

1 Answers

0
votes

This typically occurs when multiple versions of python are installed with different paths. You can check to see if you have multiple installations by opening up the IDLE terminal and using

import sys

sys.version
sys.path

These commands will print the system PATH and version of the current instance of python. Use this in both IDLE and the command line terminal to see where each differ. Once you know which version is the one you want then just remove the other. You could also remove all python instances and then reinstall a clean python environment but then you would have to re-install all of your modules using pip.