简体   繁体   中英

Cant run tensorflow on ubuntu 16.04 using python 2.7

I have installed the tensorflow using pip in python 2.7.

When I try to test the tensorflow in python, all I get is this message:

ubuntu@ubuntu:~$ python
Python 2.7.15 |Anaconda, Inc.| (default, May  1 2018, 23:32:55) 
[GCC 7.2.0] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import tensorflow as tf
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/anto/anaconda2/lib/python2.7/site-packages/tensorflow/__init__.py", line 28, in <module>
    from tensorflow.python import pywrap_tensorflow  # pylint: disable=unused-import
  File "/home/anto/anaconda2/lib/python2.7/site-packages/tensorflow/python/__init__.py", line 52, in <module>
    from tensorflow.core.framework.graph_pb2 import *
  File "/home/anto/anaconda2/lib/python2.7/site-packages/tensorflow/core/framework/graph_pb2.py", line 7, in <module>
    from google.protobuf import descriptor as _descriptor
  File "/home/anto/anaconda2/lib/python2.7/site-packages/google/protobuf/descriptor.py", line 113
    class DescriptorBase(metaclass=DescriptorMetaclass):
                                  ^
SyntaxError: invalid syntax
>>> 

I am currently running on:

  • ubuntu 16.04
  • ros1 kinematic
  • python 2.7
  • keras 2.6
  • tensorflow 1.14
  • protobuf 3.18.0

i have tried re-install a protobuf version of python 2.7 and tensorflow 1.x this is all i get to solve this problem

  • encontered error in Tensorflow 1.8 Request you to uninstall by using pip uninstall protobuf and try installing pip install protobuf==3.8
  • encontered error in Tensorflow 1.14 Request you to uninstall by using pip uninstall protobuf and try installing pip install protobuf==3.9

it works for me

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM