解决TensorFlow 1.8 安装问题
程序员文章站
2022-05-25 16:26:21
...
今天安装TensorFlow,按照官网的操作步骤,给自己的Mac安装TensorFlow,没成想,报错,错误信息如下:
>>> import tensorflow
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/tensorflow/__init__.py", line 24, in <module>
from tensorflow.python import pywrap_tensorflow # pylint: disable=unused-import
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/tensorflow/python/__init__.py", line 49, in <module>
from tensorflow.python import pywrap_tensorflow
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/tensorflow/python/pywrap_tensorflow.py", line 58, in <module>
from tensorflow.python.pywrap_tensorflow_internal import *
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/tensorflow/python/pywrap_tensorflow_internal.py", line 114
def TFE_ContextOptionsSetAsync(arg1, async):
^
SyntaxError: invalid syntax
Async invalid syntax,使用的是Python3.7,照道理,应该是能找到这个类的,搞了半天,没解决,但是找到了几个替代的方法:
1. 确保容器的python版本和你安装的tensorflow所需的python版本一致
2. 如果想继续使用这个版本的tensorflow,打开报错的文件,把这个定义的方法删除,也能正常使用
3. 终极解决办法,安装相对较低版本的tensorflow也能搞定这个问题
方法仅供参考