简体   繁体   English

在Mac中安装Tensorflow时出错

[英]Error in installing Tensorflow in mac

I am trying to install Tenosrflow in mac using the instructions from 我正在尝试使用以下说明在Mac中安装Tenosrflow

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

But I get a syntax error all the time when I want to import tensorflow. 但是我想导入tensorflow时总是遇到语法错误。

I tried uninstalling protobuf and reinstalling tensorflow, but again I get the following error: 我尝试卸载protobuf并重新安装tensorflow,但再次出现以下错误:

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): 追溯(最近一次通话最后一次):文件“”,第1行,文件“ /Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/tensorflow/init.py”,第22行,从tensorflow.python import pywrap_tensorflow#pylint:disable = unused-import文件“ /Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/tensorflow/python/init.py”中,从tensorflow.python输入的第49行,pywrap_tensorflow文件“ /Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/tensorflow/python/pywrap_tensorflow.py”,从58进入.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):

^ SyntaxError: invalid syntax` ^ SyntaxError:无效的语法`

Do you know what is the solution for this error? 您知道该错误的解决方案吗?

Thanks in advance 提前致谢

This seems to be an issue with python version 3.7 as you can also see in this github issue . 这似乎是python版本3.7的问题,您也可以在此github问题中看到。 Apparently the cause is that async is a keyword in 3.7. 显然原因是async是3.7中的关键字。 Good news is that there also seems to be a solution: 好消息是似乎也有解决方案:

As mentioned in the github issue: Renaming async to eg 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问题中所述:将async重命名为/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/tensorflow/python/pywrap_tensorflow_internal.py async1摆脱了这个问题

Note: There are multiple links inside of the github issue, also references to commits fixing 3.7. 注意:github问题内部有多个链接,还引用了修复3.7的提交。 incompatabilities, so cloning the github and installing from source might also be an option 不兼容,因此克隆github并从源代码安装可能也是一种选择

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

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