An error occurred while trying to import Tensorflow in Anaconda
I installed TensorFlow with pip3 and verified with it
# Python
import tensorflow as tf
hello = tf.constant('Hello, TensorFlow!')
sess = tf. Session()
print(sess.run(hello))
And everything works fine in the terminal. However, when I try to import tensorflow in Anaconda, it throws an error:
import tensorflow as tf
Traceback (most recent call last):
File "<ipython-input-4-64156d691fe5>", line 1, in <module>
import tensorflow as tf
File "/Users/Ivan/anaconda3/lib/python3.6/site-packages/tensorflow/__init__.py", line 24, in <module>
from tensorflow.python import *
File "/Users/Ivan/anaconda3/lib/python3.6/site-packages/tensorflow/python/__init__.py", line 51, in <module>
from tensorflow.python import pywrap_tensorflow
File "/Users/Ivan/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 "/Users/Ivan/anaconda3/lib/python3.6/site-packages/tensorflow/python/pywrap_tensorflow.py", line 41, in <module>
from tensorflow.python.pywrap_tensorflow_internal import *
File "/Users/Ivan/anaconda3/lib/python3.6/site-packages/tensorflow/python/pywrap_tensorflow_internal.py", line 28, in <module>
_pywrap_tensorflow_internal = swig_import_helper()
File "/Users/Ivan/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 "/Users/Ivan/anaconda3/lib/python3.6/imp.py", line 243, in load_module
return load_dynamic(name, filename, file)
File "/Users/Ivan/anaconda3/lib/python3.6/imp.py", line 343, in load_dynamic
return _load(spec)
ImportError: dlopen(/Users/Ivan/anaconda3/lib/python3.6/site-packages/tensorflow/python/_pywrap_tensorflow_internal.so, 10): Library not loaded: @rpath/libcublas.8.0.dylib
Referenced from: /Users/Ivan/anaconda3/lib/python3.6/site-packages/tensorflow/python/_pywrap_tensorflow_internal.so
Reason: image not found
Failed to load the native TensorFlow runtime.
I
tried something I found on the internet and that’s what I got :
When I try a command like this
conda update --all
I get “conda: command not found”. The same is true in the terminal and in the Anaconda prompt.
But if I enter in the terminalzsh conda info
Effective
If I change “Applications on…” in Anaconda from root to tensorflow, it doesn’t help.
Screenshot showing “Application on TensorFlow”:
by mistake, but I uninstalled tensorflow and reinstalled the CPU version.
I think I downloaded and installed the GPU version of tensorflow
I’m using OS X Sierra and Anaconda 4.4.10. How should I deal with this? I only have a basic understanding of terminals.
Solution
Search for Anaconda Prompt from the Start menu. Right-click on it and select Run as administrator. In the terminal that opens, type:
conda install tensorflow
This worked for me.