I just got bit by an apparent bug somehow related to Python 3.7 and TensorFlow 1.12.0 and 1.3.1 running on Raspberry Pi ARM processor:
ImportError: /usr/local/opt/python-3.7.3/lib/python3.7/site-packages/tensorflow/python/_pywrap_tensorflow_internal.so: undefined symbol: _PyThreadState_Current
Failed to load the native TensorFlow runtime.
The python distribution was installed on a RPI 0W from source, then tensorflow from Pip.
Another user reported the same error with a RPI 3 on Stack Overflow–this is his traceback:
pi@raspberrypi:~ $ python3
Python 3.7.2 (default, May 5 2019, 18:41:29)
[GCC 6.3.0 20170516] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import tensorflow
Traceback (most recent call last):
File "/usr/local/opt/python-3.7.2/lib/python3.7/site-packages/tensorflow/python/pywrap_tensorflow.py", line 58, in <module>
from tensorflow.python.pywrap_tensorflow_internal import *
File "/usr/local/opt/python-3.7.2/lib/python3.7/site-packages/tensorflow/python/pywrap_tensorflow_internal.py", line 28, in <module>
_pywrap_tensorflow_internal = swig_import_helper()
File "/usr/local/opt/python-3.7.2/lib/python3.7/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 "/usr/local/opt/python-3.7.2/lib/python3.7/imp.py", line 242, in load_module
return load_dynamic(name, filename, file)
File "/usr/local/opt/python-3.7.2/lib/python3.7/imp.py", line 342, in load_dynamic
return _load(spec)
ImportError: /usr/local/opt/python-3.7.2/lib/python3.7/site-packages/tensorflow/python/_pywrap_tensorflow_internal.so: undefined symbol: _PyThreadState_Current
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/local/opt/python-3.7.2/lib/python3.7/site-packages/tensorflow/__init__.py", line 24, in <module>
from tensorflow.python import pywrap_tensorflow # pylint: disable=unused-import
File "/usr/local/opt/python-3.7.2/lib/python3.7/site-packages/tensorflow/python/__init__.py", line 49, in <module>
from tensorflow.python import pywrap_tensorflow
File "/usr/local/opt/python-3.7.2/lib/python3.7/site-packages/tensorflow/python/pywrap_tensorflow.py", line 74, in <module>
raise ImportError(msg)
ImportError: Traceback (most recent call last):
File "/usr/local/opt/python-3.7.2/lib/python3.7/site-packages/tensorflow/python/pywrap_tensorflow.py", line 58, in <module>
from tensorflow.python.pywrap_tensorflow_internal import *
File "/usr/local/opt/python-3.7.2/lib/python3.7/site-packages/tensorflow/python/pywrap_tensorflow_internal.py", line 28, in <module>
_pywrap_tensorflow_internal = swig_import_helper()
File "/usr/local/opt/python-3.7.2/lib/python3.7/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 "/usr/local/opt/python-3.7.2/lib/python3.7/imp.py", line 242, in load_module
return load_dynamic(name, filename, file)
File "/usr/local/opt/python-3.7.2/lib/python3.7/imp.py", line 342, in load_dynamic
return _load(spec)
ImportError: /usr/local/opt/python-3.7.2/lib/python3.7/site-packages/tensorflow/python/_pywrap_tensorflow_internal.so: undefined symbol: _PyThreadState_Current
As best as I can tell, this is somehow related to several PEPs instituted with Python 3.7.x series. I am going to reattempt installing TensorFlow on most recent Python 3.6.x version and (hopefully) not duplicate the error. This is a real annoyance for anyone wanting to take advantage of TensorFlow with the latest Python 3.7.x on the Raspberry Pi.