-
Notifications
You must be signed in to change notification settings - Fork 74.7k
Invalid syntax error while importing tensorflow in python3.7.0 #20690
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for G 8000 itHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
|
duplicate of 20517 |
Any update on this issue? |
This is really annoying and unacceptable! How can we resolve this issue? |
As explained above, you can edit the last file of the trace where the error occur : |
The error is indeed resolved after your proposed change. Thanks @blured |
All you need to do is change the argument "async" to something else in "/usr/local/lib/python3.7/site-packages/tensorflow/python/pywrap_tensorflow_internal.py" in the function definition and return.. |
Nagging Assignee @bignamehyp: It has been 14 days with no activity and this issue has an assignee. Please update the label and/or status accordingly. |
This is weird. Needs to be fixed. |
some here |
@yifeif can you please take a look? Thanks. |
hi guys i have the same problem, i just did install tensor to mac sierra 12.10.6 im using python3 and voala !!
thank you @tiehexue i did update right in pywrap_tensorflow_internal.py async for async1 , and woks !! ... the lastone was on line 155 , thank you so much ! |
Actually, there are four lines with |
This worked for me. YMMV (modify the path). |
This worked for me, but if you are changing the
then also please change the arguments in the return type, as they are also mentioned with the 'asyc'. |
I'm facing the same issue for Python 3.6.6. Is Python 3.6.6 not supported as well? |
per the instructions above, after changing the "async" argument and returned variable names to async1, python quits on importing tensorflow. |
per the instructions above, after changing the "async" argument and returned variable names to async1 as folowing: def TFE_ContextSetasyncForThread(arg1, async1): There is another problem for me:_Traceback (most recent call last): |
wrong syntax |
Hi everyone can you enlighten me I barely get Tensorflow running every time he returns these errors Traceback (most recent call last): During handling of the above exception, another exception occurred: Traceback (most recent call last): Failed to load the native TensorFlow runtime. See https://www.tensorflow.org/install/errors for some common reasons and solutions. Include the entire stack trace |
after changing async to async1 i got the next error 👍 Using TensorFlow backend. During handling of the above exception, another exception occurred: Traceback (most recent call last): During handling of the above exception, another exception occurred: Traceback (most recent call last): During handling of the above exception, another exception occurred: Traceback (most recent call last): Failed to load the native TensorFlow runtime. See https://www.tensorflow.org/install/install_sources#common_installation_problems for some common reasons and solutions. Include the entire stack trace any idea? |
I too have the same problem. Can anyone solve this issue? |
I've installed tensorflow using pip and encountered with module not found error. Based on some of the previous conversations I've uninstalled it and re-installed tensorflow via conda. The installation was successfull but it produces Syntax Error which have been attached below. Traceback (most recent call last): File "c:\users\elcot\anaconda3\envs'virtual_env'\lib\site-packages\IPython\core\interactiveshell.py", line 3331, in run_code File "", line 1, in File "c:\users\elcot\anaconda3\envs'virtual_env'\lib\site-packages\tensorflow_init_.py", line 101, in File "c:\users\elcot\anaconda3\envs'virtual_env'\lib\site-packages\tensorflow_core_init_.py", line 46, in File "c:\users\elcot\anaconda3\envs'virtual_env'\lib\site-packages\tensorflow_core_api\v2\compat_init_.py", line 39, in File "c:\users\elcot\anaconda3\envs'virtual_env'\lib\site-packages\tensorflow_core_api\v2\compat\v1_init_.py", line 32, in File "c:\users\elcot\anaconda3\envs'virtual_env'\lib\site-packages\tensorflow_core_api\v2\compat\v1\compat_init_.py", line 39, in File "c:\users\elcot\anaconda3\envs'virtual_env'\lib\site-packages\tensorflow_core_api\v2\compat\v1\compat\v1_init_.py", line 29, in File "c:\users\elcot\anaconda3\envs'virtual_env'\lib\site-packages\tensorflow_core_api\v2\compat_init_.py", line 39, in File "c:\users\elcot\anaconda3\envs'virtual_env'\lib\site-packages\tensorflow_core_api\v2\compat\v1_init_.py", line 32, in File "c:\users\elcot\anaconda3\envs'virtual_env'\lib\site-packages\tensorflow_core_api\v2\compat\v1\compat_init_.py", line 39, in File "c:\users\elcot\anaconda3\envs'virtual_env'\lib\site-packages\tensorflow_core_api\v2\compat\v1\compat\v1_init_.py", line 35, in File "c:\users\elcot\anaconda3\envs'virtual_env'\lib\site-packages\tensorflow_core_api\v2\compat\v1\debugging_init_.py", line 10, in File "c:\users\elcot\anaconda3\envs'virtual_env'\lib\site-packages\tensorflow_core_api\v2\compat\v1\debugging\experimental_init_.py", line 10, in File "c:\users\elcot\anaconda3\envs'virtual_env'\lib\site-packages\tensorflow_core\python\debug\lib\dumping_callback.py", line 29, in File "c:\users\elcot\anaconda3\envs'virtual_env'\lib\site-packages\tensorflow_core\python\debug\lib\debug_events_writer.py", line 24, in File "", line 1020, in _handle_fromlist File "c:\users\elcot\anaconda3\envs'virtual_env'\lib\site-packages\tensorflow_init_.py", line 50, in getattr File "c:\users\elcot\anaconda3\envs'virtual_env'\lib\site-packages\tensorflow_init_.py", line 44, in _load File "c:\users\elcot\anaconda3\envs'virtual_env'\lib\importlib_init_.py", line 126, in import_module File "c:\users\elcot\anaconda3\envs'virtual_env'\lib\site-packages\tensorflow_core\python_init_.py", line 95, in File "c:\users\elcot\anaconda3\envs'virtual_env'\lib\site-packages\tensorflow_core\python\keras_init_.py", line 27, in File "c:\users\elcot\anaconda3\envs'virtual_env'\lib\site-packages\tensorflow_core\python\keras_init_.py", line 27, in File "c:\users\elcot\anaconda3\envs'virtual_env'\lib\site-packages\tensorflow_core\python\keras\models.py", line 26, in File "c:\users\elcot\anaconda3\envs'virtual_env'\lib\site-packages\tensorflow_core\python\keras\engine\sequential.py", line 28, in File "c:\users\elcot\anaconda3\envs'virtual_env'\lib\site-packages\tensorflow_core\python\keras\engine\training.py", line 46, in File "c:\users\elcot\anaconda3\envs'virtual_env'\lib\site-packages\tensorflow_core\python\keras\engine\training_arrays.py", line 41, in File "c:\users\elcot\anaconda3\envs'virtual_env'\lib\site-packages\scipy_init_.py", line 131, in File "c:\users\elcot\anaconda3\envs'virtual_env'\lib\site-packages\scipy_config_.py", line 13 Can anyone help me out with this issue? |
So after changing async to async1 , I am also facing the same problem Any solution? Python 3.9.2 |
Locate the pywrap_tensorflow_internal.py. It's generally in
python3.7/site-packages/tensorflow/python/
Open any text editor (I prefer atom).
Find async on the mentioned lines and replace it with async1.
Dont forget to take a backup of pywrap_tensorflow_internal.py in case
something goes wrong.
…On Wed, Apr 21, 2021 at 12:08 AM LesLuger ***@***.***> wrote:
As explained above, you can edit the last file of the trace where the
error occur :
/usr/local/lib/python3.7/site-packages/tensorflow/python/pywrap_tensorflow_internal.py
and find anywhere the variable async is used and replace it with async1 so
its not a python 3.7 keyword anymore. you will find those "async" variables
on line 114, 115, 150
So this (for instance):
def TFE_ContextOptionsSetAsync(arg1, async):
becomes this:
def TFE_ContextOptionsSetAsync(arg1, async1):
Hope this helps !
how do you open the file to edit?
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
<#20690 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AL3UPJ2J5KLRGMAGJOMGJHTTJXC2XANCNFSM4FJLNJKA>
.
|
File C:\ProgramData\Anaconda3\lib\site-packages\tensorflow\python\pywrap_tensorflow_internal.py:114 |
System information
OS Platform and Distribution (e.g., Linux Ubuntu 16.04):
MacOS High Sierra 10.13.5
TensorFlow installed from (source or binary):
pip3
TensorFlow version (use command below):
1.9.0
Python version:
3.7.0
Exact command to reproduce:
import tensorflow as tf
Describe the problem
when import tensorflow in python3 prompt, it says "SyntaxError: invalid syntax".
Traceback (most recent call last):
File "", line 1, in
File "/usr/local/lib/python3.7/site-packages/tensorflow/init.py", line 22, in
from tensorflow.python import pywrap_tensorflow # pylint: disable=unused-import
File "/usr/local/lib/python3.7/site-packages/tensorflow/python/init.py", line 49, in
from tensorflow.python import pywrap_tensorflow
File "/usr/local/lib/python3.7/site-packages/tensorflow/python/pywrap_tensorflow.py", line 58, in
from tensorflow.python.pywrap_tensorflow_internal import *
File "/usr/local/lib/python3.7/site-packages/tensorflow/python/pywrap_tensorflow_internal.py", line 114
def TFE_ContextOptionsSetAsync(arg1, async):_
^
SyntaxError: invalid syntax
Source code / logs
line 114, 115, 150 of pywrap_tensorflow_internal.py has "async" as parameter which seems to be a keyword.
After changed to "async1", importing tensorflow works.
def TFE_ContextOptionsSetAsync(arg1, async1):
return _pywrap_tensorflow_internal.TFE_ContextOptionsSetAsync(arg1, async1)
TFE_ContextOptionsSetAsync = _pywrap_tensorflow_internal.TFE_ContextOptionsSetAsync
The text was updated successfully, but these errors were encountered: