简体   繁体   English

无法使用 python 2.7 在 ubuntu 16.04 上运行 tensorflow

[英]Cant run tensorflow on ubuntu 16.04 using python 2.7

I have installed the tensorflow using pip in python 2.7.我已经在 python 2.7 中使用 pip 安装了 tensorflow。

When I try to test the tensorflow in python, all I get is this message:当我尝试在 python 中测试张量流时,我得到的只是这条消息:

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 Ubuntu 16.04
  • ros1 kinematic ros1 运动学
  • python 2.7蟒蛇 2.7
  • keras 2.6 keras 2.6
  • tensorflow 1.14张量流 1.14
  • protobuf 3.18.0 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我已经尝试重新安装 python 2.7 和 tensorflow 1.x 的 protobuf 版本这就是我解决这个问题的全部方法

  • encontered error in Tensorflow 1.8 Request you to uninstall by using pip uninstall protobuf and try installing pip install protobuf==3.8在 Tensorflow 1.8 中遇到错误请求您使用pip uninstall protobuf并尝试安装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在 Tensorflow 1.14 中遇到错误请求您使用pip uninstall protobuf并尝试安装pip install protobuf==3.9

it works for me这个对我有用

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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