gpt4 book ai didi

python - 在 Ubuntu 16.04 上的 Python 3 中导入 tensorflow 时出错 SyntaxError : l. append ("%s=%s"% (attr, `value` ))

转载 作者:太空宇宙 更新时间:2023-11-04 04:54:46 24 4
gpt4 key购买 nike

  1. 我在我的 Linux Mint (Ubuntu 16.04 Xenial) 上安装了 python 3.5
  2. 我还使用 pip3 install protobuf 安装了 protobuf
  3. 我使用 pip3 install tensorflow
  4. 安装了 tensorflow

然后我尝试在 python 3 中导入 tensorflow,但失败并出现以下错误:

Traceback (most recent call last):
File "/home/abdullah/face_recognition/tensorflow_test.py", line 1, in <module>
import tensorflow
File "/usr/local/lib/python3.5/dist-packages/tensorflow/__init__.py", line 24, in <module>
from tensorflow.python import *
File "/usr/local/lib/python3.5/dist-packages/tensorflow/python/__init__.py", line 83, in <module>
from tensorflow.python.estimator import estimator_lib as estimator
File "/usr/local/lib/python3.5/dist-packages/tensorflow/python/estimator/estimator_lib.py", line 35, in <module>
from tensorflow.python.estimator.inputs import inputs
File "/usr/local/lib/python3.5/dist-packages/tensorflow/python/estimator/inputs/inputs.py", line 22, in <module>
from tensorflow.python.estimator.inputs.numpy_io import numpy_input_fn
File "/usr/local/lib/python3.5/dist-packages/tensorflow/python/estimator/inputs/numpy_io.py", line 22, in <module>
from tensorflow.python.estimator.inputs.queues import feeding_functions
File "/usr/local/lib/python3.5/dist-packages/tensorflow/python/estimator/inputs/queues/feeding_functions.py", line 40, in <module>
import pandas as pd
File "/usr/local/lib/python3.5/dist-packages/pandas/__init__.py", line 23, in <module>
from pandas.compat.numpy import *
File "/usr/local/lib/python3.5/dist-packages/pandas/compat/__init__.py", line 361, in <module>
from dateutil import parser as _date_parser
File "/usr/local/lib/python3.5/dist-packages/dateutil/parser.py", line 158
l.append("%s=%s" % (attr, `value`))
^
SyntaxError: invalid syntax

咨询了 SO 和其他论坛上发布的许多问题,我尝试卸载 protobuf 然后遇到以下错误。

Traceback (most recent call last):
File "/home/abdullah/face_recognition/tensorflow_test.py", line 1, in <module>
import tensorflow
File "/usr/local/lib/python3.5/dist-packages/tensorflow/__init__.py", line 24, in <module>
from tensorflow.python import *
File "/usr/local/lib/python3.5/dist-packages/tensorflow/python/__init__.py", line 52, in <module>
from tensorflow.core.framework.graph_pb2 import *
File "/usr/local/lib/python3.5/dist-packages/tensorflow/core/framework/graph_pb2.py", line 6, in <module>
from google.protobuf import descriptor as _descriptor
ImportError: No module named 'google.protobuf'

目前我只是这一切的初学者。我不明白为什么需要 protobuf 为什么要这么麻烦?我只是想在我的系统上安装 tensorflow 并尝试学习一些东西。

最佳答案

我也遇到了同样的问题。我认为的问题是这是使用系统(apt-get)存储库中的 pandas,它与其他库不兼容。更新 pandas 就可以了。

pip3 install --upgrade pandas

同样在您的情况下,如果仅执行上述操作失败,您还可以尝试使用升级选项重新安装 tensorflowprotobuf

pip3 install --upgrade protobuf
pip3 install --upgrade tensorflow

关于python - 在 Ubuntu 16.04 上的 Python 3 中导入 tensorflow 时出错 SyntaxError : l. append ("%s=%s"% (attr, `value` )),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47323828/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com