Error in installing Tensorflow in mac

好久不见. 提交于 2020-01-06 07:20:12

问题


I am trying to install Tenosrflow in mac using the instructions from

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

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

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

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?

Thanks in advance


回答1:


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:

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

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



来源:https://stackoverflow.com/questions/51824226/error-in-installing-tensorflow-in-mac

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!