2

I am on raspberry pi 3. Running Raspbian 9. Python version 3.7.2 installed following https://neoctobers.readthedocs.io/en/latest/rpi/install_python3.html. Made python3 point to python3.7.2 using update-alternatives --install /usr/bin/python3 python3 /usr/bin/python3.7 1

This is the error I am getting:

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

Thanks in advance.

1
  • 1
    I have the same problem with python3.7.3. Commented May 17, 2019 at 18:42

1 Answer 1

0

There is an approved issue with Tensorflow wheel and Python 3.7 (https://github.com/bennuttall/piwheels/issues/146). Looks like there is no way to solve it gently.

I was managed to successfully install tensorflow 1.13.0 on my RPi3 with Python 3.5.3:

$ python3 --version
Python 3.5.3

$ pip3 freeze | grep tensorflow
tensorflow==1.13.1
tensorflow-estimator==1.13.0

This setup works, but tensorflow raises warnings related to runtime version compatibility:

$ python3 -c "import tensorflow as tf; tf.enable_eager_execution(); print(tf.reduce_sum(tf.random_normal([1000, 1000])))"
/usr/lib/python3.5/importlib/_bootstrap.py:222: RuntimeWarning: compiletime version 3.4 of module 'tensorflow.python.framework.fast_tensor_util' does not match runtime version 3.5
  return f(*args, **kwds)
/usr/lib/python3.5/importlib/_bootstrap.py:222: RuntimeWarning: builtins.type size changed, may indicate binary incompatibility. Expected 432, got 412
  return f(*args, **kwds)
tf.Tensor(624.73706, shape=(), dtype=float32)

You may try to live with those warnings (suppress them) or consider alternative tensorflow build for RPi from this repo https://github.com/lhelontra/tensorflow-on-arm/releases (looks like it's available for Python 3.5 and 2.7 only):

$ pip3 install https://github.com/lhelontra/tensorflow-on-arm/releases/download/v1.13.1/tensorflow-1.13.1-cp35-none-linux_armv7l.whl

In my case it works fine without any warnings:

$ python3 -c "import tensorflow as tf; tf.enable_eager_execution(); print(tf.reduce_sum(tf.random_normal([1000, 1000])))"
tf.Tensor(448.25854, shape=(), dtype=float32)
Sign up to request clarification or add additional context in comments.

1 Comment

Yes I faced these warnings and had decided to live with it. But then tflearn had problems with it. That is why I decided to try Python3.7. But a while ago, on a magical 10th ish reinstall it worked. No idea why. I did what you answered too! Had come to delete this question when I saw this answer. Thanks for the help. Marking it as correct.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.