Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Python unable to import tensorflow to Mac OS X 10.8

I am trying to install tensorflow on my mac air (specs: OSX 10.8.4, 4GB RAM). While tensorflow installs cleanly, as on the tensorflow.org page, and I am able to do $ source bin/activate to get a tensorflow prompt, I am not able to import the package in python. This is what I get:

    >>> import tensorflow
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/local/lib/python2.7/site-packages/tensorflow/__init__.py", line 4, in <module>
    from tensorflow.python import *
  File "/usr/local/lib/python2.7/site-packages/tensorflow/python/__init__.py", line 22, in <module>
    from tensorflow.python.client.client_lib import *
  File "/usr/local/lib/python2.7/site-packages/tensorflow/python/client/client_lib.py", line 35, in <module>
    from tensorflow.python.client.session import InteractiveSession
  File "/usr/local/lib/python2.7/site-packages/tensorflow/python/client/session.py", line 11, in <module>
    from tensorflow.python import pywrap_tensorflow as tf_session
  File "/usr/local/lib/python2.7/site-packages/tensorflow/python/pywrap_tensorflow.py", line 28, in <module>
    _pywrap_tensorflow = swig_import_helper()
  File "/usr/local/lib/python2.7/site-packages/tensorflow/python/pywrap_tensorflow.py", line 24, in swig_import_helper
    _mod = imp.load_module('_pywrap_tensorflow', fp, pathname, description)
ImportError: dlopen(/usr/local/lib/python2.7/site-packages/tensorflow/python/_pywrap_tensorflow.so, 2): Symbol not found: ___sincos_stret
  Referenced from: /usr/local/lib/python2.7/site-packages/tensorflow/python/_pywrap_tensorflow.so
  Expected in: /usr/lib/libSystem.B.dylib
 in /usr/local/lib/python2.7/site-packages/tensorflow/python/_pywrap_tensorflow.so

I looked at the common problems section on tensorflow, as well as searched for the ImportError above but have had no luck so far. I wonder if this is a protobuf issue as referenced in Error in python after 'import tensorflow': TypeError: __init__() got an unexpected keyword argument 'syntax' . Thanks in advance.

like image 382
Dwoito Avatar asked Sep 26 '22 06:09

Dwoito


1 Answers

The issue appears to be that the binary distribution of TensorFlow is not compatible with Mac OS X 10.8. The relevant part of the error message is this one:

Symbol not found: ___sincos_stret

According to various sources, this is a known issue when using binaries compiled for a newer version of Mac OS X on 10.8 (Mavericks), because the symbol ___sincos_stret is not defined in the standard libraries for that version of the OS.

To address this, you will need to (i) upgrade to Mac OS X 10.9 or later, (ii) follow the instructions to install from source, or (iii) use Docker.

like image 171
mrry Avatar answered Sep 29 '22 21:09

mrry