在mac中安装Tensorflow时出错 [英] Error in installing Tensorflow in mac

查看:51
本文介绍了在mac中安装Tensorflow时出错的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用来自

https://www.tensorflow.org/install/

但是当我想导入 tensorflow 时,总是出现语法错误.

But I get a syntax error all the time when I want to import tensorflow.

我尝试卸载 protobuf 并重新安装 tensorflow,但再次出现以下错误:

I tried uninstalling protobuf and reinstalling tensorflow, but again I get the following error:

回溯(最近一次调用最后一次):文件",第 1 行,在文件中"/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/tensorflow/init.py",第 22 行,在 from tensorflow.python import pywrap_tensorflow # pylint:禁用=未使用的导入文件"/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/tensorflow/python/init.py",第 49 行,从 tensorflow.python 导入 pywrap_tensorflow 文件"/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/tensorflow/python/pywrap_tensorflow.py",第 58 行,来自 tensorflow.python.pywrap_tensorflow_internal import *文件"/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/tensorflow/python/pywrap_tensorflow_internal.py",第 114 行 def TFE_ContextOptionsSetAsync(arg1, async):

Traceback (most recent call last): File "", line 1, in File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/tensorflow/init.py", line 22, in 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 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 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`

你知道这个错误的解决方法是什么吗?

Do you know what is the solution for this error?

提前致谢

推荐答案

这似乎是 Python 3.7 版的问题,您也可以在 这个 github 问题.显然原因是 async 是 3.7 中的关键字.好消息是,似乎也有一个解决方案:

This seems to be an issue with python version 3.7 as you can also see in this github issue. Apparently the cause is that async is a keyword in 3.7. Good news is that there also seems to be a solution:

如 github 问题中所述:将 async 重命名为例如/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/tensorflow/python/pywrap_tensorflow_internal.py 中的 async1 去掉了问题

As mentioned in the github issue: Renaming async to e.g. async1 in /Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/tensorflow/python/pywrap_tensorflow_internal.py gets rid of the issue

注意:github 问题中有多个链接,还引用了修复 3.7 的提交.不兼容,因此克隆 github 和 从源代码安装 也可能是一种选择

Note: There are multiple links inside of the github issue, also references to commits fixing 3.7. incompatabilities, so cloning the github and installing from source might also be an option

这篇关于在mac中安装Tensorflow时出错的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆