Skip to content
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 GitHub”, 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

Invalid syntax error while importing tensorflow in python3.7.0 #20690

Closed
tiehexue opened this issue Jul 11, 2018 · 30 comments
Closed

Invalid syntax error while importing tensorflow in python3.7.0 #20690

tiehexue opened this issue Jul 11, 2018 · 30 comments
Assignees
Labels
stat:awaiting tensorflower Status - Awaiting response from tensorflower

Comments

@tiehexue
Copy link

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

@wkpn
Copy link

wkpn commented Jul 11, 2018

async and await are reserved keywords in python 3.7

@smcveigh-phunware
Copy link

duplicate of 20517

@murthyteja
Copy link

Any update on this issue?

@mhyousefi
Copy link

This is really annoying and unacceptable! How can we resolve this issue?

@blured
Copy link

blured commented Aug 5, 2018

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 !

@mhyousefi
Copy link

mhyousefi commented Aug 5, 2018

The error is indeed resolved after your proposed change. Thanks @blured

@Manish-rai21bit
Copy link

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..

@tensorflowbutler
Copy link
Member

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.

@yazeed
Copy link

yazeed commented Aug 27, 2018

This is weird. Needs to be fixed.

@xellDart
Copy link

some here

@bignamehyp
Copy link
Member

@yifeif can you please take a look? Thanks.

@bignamehyp bignamehyp added the stat:awaiting tensorflower Status - Awaiting response from tensorflower label Aug 30, 2018
@dg1618
Copy link

dg1618 commented Sep 1, 2018

hi guys i have the same problem, i just did install tensor to mac sierra 12.10.6 im using python3 and

voala !!
SyntaxError: invalid syntax

import tensorflow as tf
Traceback (most recent call last):
File "", line 1, in
File "/Users/juaporra/Library/Python/3.7/lib/python/site-packages/tensorflow/init.py", line 22, in
from tensorflow.python import pywrap_tensorflow # pylint: disable=unused-import
File "/Users/juaporra/Library/Python/3.7/lib/python/site-packages/tensorflow/python/init.py", line 49, in
from tensorflow.python import pywrap_tensorflow
File "/Users/juaporra/Library/Python/3.7/lib/python/site-packages/tensorflow/python/pywrap_tensorflow.py", line 58, in
from tensorflow.python.pywrap_tensorflow_internal import *
File "/Users/juaporra/Library/Python/3.7/lib/python/site-packages/tensorflow/python/pywrap_tensorflow_internal.py", line 114
def TFE_ContextOptionsSetAsync(arg1, async):

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 !

@AFAgarap
Copy link

AFAgarap commented Sep 3, 2018

Actually, there are four lines with async: 114, 115, 154, and 155.

@dimidd
Copy link

dimidd commented Sep 4, 2018

This worked for me. YMMV (modify the path).
sudo sed -i 's/async/async_py3/g' /usr/local/lib/python3.7/site-packages/tensorflow/python/pywrap_tensorflow_internal.py

@codedsun
Copy link

codedsun commented Sep 5, 2018

This worked for me, but if you are changing the

def TFE_ContextOptionsSetAsync(arg1, async):
becomes this:
def TFE_ContextOptionsSetAsync(arg1, async1):

then also please change the arguments in the return type, as they are also mentioned with the 'asyc'.

@yifeif
Copy link
Contributor

yifeif commented Sep 5, 2018

I believe this should be fixed by #21202 (thanks to @bstriner) if you build from source. But looks like there won't be a python 3.7 pypi package for 1.11, cc @gunan.

@yifeif yifeif closed this as completed Sep 5, 2018
@souravb65
Copy link

I'm facing the same issue for Python 3.6.6. Is Python 3.6.6 not supported as well?

@mikeyj777
Copy link

mikeyj777 commented Sep 22, 2018

per the instructions above, after changing the "async" argument and returned variable names to async1, python quits on importing tensorflow.

@BTUJACK
Copy link

BTUJACK commented Oct 15, 2018

per the instructions above, after changing the "async" argument and returned variable names to async1 as folowing:
def TFE_ContextOptionsSetasync(arg1, async1):
return _pywrap_tensorflow_internal.TFE_ContextOptionsSetasync(arg1, async1)

def TFE_ContextSetasyncForThread(arg1, async1):
return _pywrap_tensorflow_internal.TFE_ContextSetasyncForThread(arg1, async1)

There is another problem for me:

_Traceback (most recent call last):
File "/Users/apple/Documents/ST/python/test.py", line 1, in
import tensorflow as tf
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 116, in
TFE_ContextOptionsSetasync = _pywrap_tensorflow_internal.TFE_ContextOptionsSetasync
AttributeError: module 'pywrap_tensorflow_internal' has no attribute 'TFE_ContextOptionsSetasync'

@Windsmild
Copy link

This worked for me. YMMV (modify the path).
sudo sed -i 's/async/async_py3/g' /usr/local/lib/python3.7/site-packages/tensorflow/python/pywrap_tensorflow_internal.py

wrong syntax
should be
sudo sed -i "backupname" 's/async/async_py3/g' /usr/local/lib/python3.7/site-packages/tensorflow/python/pywrap_tensorflow_internal.py
and work

@wd456
Copy link

wd456 commented Mar 28, 2019

Hi everyone can you enlighten me I barely get Tensorflow running every time he returns these errors

Traceback (most recent call last):
File "C:\Users\WD\AppData\Local\Programs\Python\Python37\lib\site-packages\tensorflow\python\pywrap_tensorflow.py", line 58, in
from tensorflow.python.pywrap_tensorflow_internal import *
File "C:\Users\WD\AppData\Local\Programs\Python\Python37\lib\site-packages\tensorflow\python\pywrap_tensorflow_internal.py", line 28, in
_pywrap_tensorflow_internal = swig_import_helper()
File "C:\Users\WD\AppData\Local\Programs\Python\Python37\lib\site-packages\tensorflow\python\pywrap_tensorflow_internal.py", line 24, in swig_import_helper
_mod = imp.load_module('_pywrap_tensorflow_internal', fp, pathname, description)
File "C:\Users\WD\AppData\Local\Programs\Python\Python37\lib\imp.py", line 242, in load_module
return load_dynamic(name, filename, file)
File "C:\Users\WD\AppData\Local\Programs\Python\Python37\lib\imp.py", line 342, in load_dynamic
return _load(spec)
ImportError: DLL load failed: Une routine d’initialisation d’une bibliothèque de liens dynamiques (DLL) a échoué.

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "<pyshell#0>", line 1, in
from tensorflow.python.pywrap_tensorflow_internal import *
File "C:\Users\WD\AppData\Local\Programs\Python\Python37\lib\site-packages\tensorflow_init_.py", line 24, in
from tensorflow.python import pywrap_tensorflow # pylint: disable=unused-import
File "C:\Users\WD\AppData\Local\Programs\Python\Python37\lib\site-packages\tensorflow\python_init_.py", line 49, in
from tensorflow.python import pywrap_tensorflow
File "C:\Users\WD\AppData\Local\Programs\Python\Python37\lib\site-packages\tensorflow\python\pywrap_tensorflow.py", line 74, in
raise ImportError(msg)
ImportError: Traceback (most recent call last):
File "C:\Users\WD\AppData\Local\Programs\Python\Python37\lib\site-packages\tensorflow\python\pywrap_tensorflow.py", line 58, in
from tensorflow.python.pywrap_tensorflow_internal import *
File "C:\Users\WD\AppData\Local\Programs\Python\Python37\lib\site-packages\tensorflow\python\pywrap_tensorflow_internal.py", line 28, in
_pywrap_tensorflow_internal = swig_import_helper()
File "C:\Users\WD\AppData\Local\Programs\Python\Python37\lib\site-packages\tensorflow\python\pywrap_tensorflow_internal.py", line 24, in swig_import_helper
_mod = imp.load_module('_pywrap_tensorflow_internal', fp, pathname, description)
File "C:\Users\WD\AppData\Local\Programs\Python\Python37\lib\imp.py", line 242, in load_module
return load_dynamic(name, filename, file)
File "C:\Users\WD\AppData\Local\Programs\Python\Python37\lib\imp.py", line 342, in load_dynamic
return _load(spec)
ImportError: DLL load failed: Une routine d’initialisation d’une bibliothèque de liens dynamiques (DLL) a échoué.

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
above this error message when asking for help.

@firas94mecha
Copy link

after changing async to async1 i got the next error 👍 Using TensorFlow backend.
Traceback (most recent call last):
File "C:\Users\Firas\AppData\Local\Programs\Python\Python38-32\lib\site-packages\tensorflow\python\pywrap_tensorflow_internal.py", line 18, in swig_import_helper
fp, pathname, description = imp.find_module('_pywrap_tensorflow_internal', [dirname(file)])
File "C:\Users\Firas\AppData\Local\Programs\Python\Python38-32\lib\imp.py", line 296, in find_module
raise ImportError(_ERR_MSG.format(name), name=name)
ImportError: No module named '_pywrap_tensorflow_internal'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "C:\Users\Firas\AppData\Local\Programs\Python\Python38-32\lib\site-packages\tensorflow\python\pywrap_tensorflow.py", line 58, in
from tensorflow.python.pywrap_tensorflow_internal import *
File "C:\Users\Firas\AppData\Local\Programs\Python\Python38-32\lib\site-packages\tensorflow\python\pywrap_tensorflow_internal.py", line 28, in
_pywrap_tensorflow_internal = swig_import_helper()
File "C:\Users\Firas\AppData\Local\Programs\Python\Python38-32\lib\site-packages\tensorflow\python\pywrap_tensorflow_internal.py", line 20, in swig_import_helper
import _pywrap_tensorflow_internal
ModuleNotFoundError: No module named '_pywrap_tensorflow_internal'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "C:/Users/Firas/Desktop/f8.py", line 1, in
from keras.datasets import mnist
File "C:\Users\Firas\AppData\Local\Programs\Python\Python38-32\lib\site-packages\keras_init_.py", line 3, in
from . import utils
File "C:\Users\Firas\AppData\Local\Programs\Python\Python38-32\lib\site-packages\keras\utils_init_.py", line 6, in
from . import conv_utils
File "C:\Users\Firas\AppData\Local\Programs\Python\Python38-32\lib\site-packages\keras\utils\conv_utils.py", line 9, in
from .. import backend as K
File "C:\Users\Firas\AppData\Local\Programs\Python\Python38-32\lib\site-packages\keras\backend_init_.py", line 1, in
from .load_backend import epsilon
File "C:\Users\Firas\AppData\Local\Programs\Python\Python38-32\lib\site-packages\keras\backend\load_backend.py", line 90, in
from .tensorflow_backend import *
File "C:\Users\Firas\AppData\Local\Programs\Python\Python38-32\lib\site-packages\keras\backend\tensorflow_backend.py", line 5, in
import tensorflow as tf
File "C:\Users\Firas\AppData\Local\Programs\Python\Python38-32\lib\site-packages\tensorflow_init_.py", line 24, in
from tensorflow.python import pywrap_tensorflow # pylint: disable=unused-import
File "C:\Users\Firas\AppData\Local\Programs\Python\Python38-32\lib\site-packages\tensorflow\python_init_.py", line 49, in
from tensorflow.python import pywrap_tensorflow
File "C:\Users\Firas\AppData\Local\Programs\Python\Python38-32\lib\site-packages\tensorflow\python\pywrap_tensorflow.py", line 74, in
raise ImportError(msg)
ImportError: Traceback (most recent call last):
File "C:\Users\Firas\AppData\Local\Programs\Python\Python38-32\lib\site-packages\tensorflow\python\pywrap_tensorflow_internal.py", line 18, in swig_import_helper
fp, pathname, description = imp.find_module('_pywrap_tensorflow_internal', [dirname(file)])
File "C:\Users\Firas\AppData\Local\Programs\Python\Python38-32\lib\imp.py", line 296, in find_module
raise ImportError(_ERR_MSG.format(name), name=name)
ImportError: No module named '_pywrap_tensorflow_internal'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "C:\Users\Firas\AppData\Local\Programs\Python\Python38-32\lib\site-packages\tensorflow\python\pywrap_tensorflow.py", line 58, in
from tensorflow.python.pywrap_tensorflow_internal import *
File "C:\Users\Firas\AppData\Local\Programs\Python\Python38-32\lib\site-packages\tensorflow\python\pywrap_tensorflow_internal.py", line 28, in
_pywrap_tensorflow_internal = swig_import_helper()
File "C:\Users\Firas\AppData\Local\Programs\Python\Python38-32\lib\site-packages\tensorflow\python\pywrap_tensorflow_internal.py", line 20, in swig_import_helper
import _pywrap_tensorflow_internal
ModuleNotFoundError: No module named '_pywrap_tensorflow_internal'

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
above this error message when asking for help.

any idea?

@its-akhr
Copy link

its-akhr commented Mar 7, 2020

after changing async to async1 i got the next error 👍 Using TensorFlow backend.
Traceback (most recent call last):
File "C:\Users\Firas\AppData\Local\Programs\Python\Python38-32\lib\site-packages\tensorflow\python\pywrap_tensorflow_internal.py", line 18, in swig_import_helper
fp, pathname, description = imp.find_module('_pywrap_tensorflow_internal', [dirname(file)])
File "C:\Users\Firas\AppData\Local\Programs\Python\Python38-32\lib\imp.py", line 296, in find_module
raise ImportError(_ERR_MSG.format(name), name=name)
ImportError: No module named '_pywrap_tensorflow_internal'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "C:\Users\Firas\AppData\Local\Programs\Python\Python38-32\lib\site-packages\tensorflow\python\pywrap_tensorflow.py", line 58, in
from tensorflow.python.pywrap_tensorflow_internal import *
File "C:\Users\Firas\AppData\Local\Programs\Python\Python38-32\lib\site-packages\tensorflow\python\pywrap_tensorflow_internal.py", line 28, in
_pywrap_tensorflow_internal = swig_import_helper()
File "C:\Users\Firas\AppData\Local\Programs\Python\Python38-32\lib\site-packages\tensorflow\python\pywrap_tensorflow_internal.py", line 20, in swig_import_helper
import _pywrap_tensorflow_internal
ModuleNotFoundError: No module named '_pywrap_tensorflow_internal'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "C:/Users/Firas/Desktop/f8.py", line 1, in
from keras.datasets import mnist
File "C:\Users\Firas\AppData\Local\Programs\Python\Python38-32\lib\site-packages\keras__init__.py", line 3, in
from . import utils
File "C:\Users\Firas\AppData\Local\Programs\Python\Python38-32\lib\site-packages\keras\utils__init__.py", line 6, in
from . import conv_utils
File "C:\Users\Firas\AppData\Local\Programs\Python\Python38-32\lib\site-packages\keras\utils\conv_utils.py", line 9, in
from .. import backend as K
File "C:\Users\Firas\AppData\Local\Programs\Python\Python38-32\lib\site-packages\keras\backend__init__.py", line 1, in
from .load_backend import epsilon
File "C:\Users\Firas\AppData\Local\Programs\Python\Python38-32\lib\site-packages\keras\backend\load_backend.py", line 90, in
from .tensorflow_backend import *
File "C:\Users\Firas\AppData\Local\Programs\Python\Python38-32\lib\site-packages\keras\backend\tensorflow_backend.py", line 5, in
import tensorflow as tf
File "C:\Users\Firas\AppData\Local\Programs\Python\Python38-32\lib\site-packages\tensorflow__init__.py", line 24, in
from tensorflow.python import pywrap_tensorflow # pylint: disable=unused-import
File "C:\Users\Firas\AppData\Local\Programs\Python\Python38-32\lib\site-packages\tensorflow\python__init__.py", line 49, in
from tensorflow.python import pywrap_tensorflow
File "C:\Users\Firas\AppData\Local\Programs\Python\Python38-32\lib\site-packages\tensorflow\python\pywrap_tensorflow.py", line 74, in
raise ImportError(msg)
ImportError: Traceback (most recent call last):
File "C:\Users\Firas\AppData\Local\Programs\Python\Python38-32\lib\site-packages\tensorflow\python\pywrap_tensorflow_internal.py", line 18, in swig_import_helper
fp, pathname, description = imp.find_module('_pywrap_tensorflow_internal', [dirname(file)])
File "C:\Users\Firas\AppData\Local\Programs\Python\Python38-32\lib\imp.py", line 296, in find_module
raise ImportError(_ERR_MSG.format(name), name=name)
ImportError: No module named '_pywrap_tensorflow_internal'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "C:\Users\Firas\AppData\Local\Programs\Python\Python38-32\lib\site-packages\tensorflow\python\pywrap_tensorflow.py", line 58, in
from tensorflow.python.pywrap_tensorflow_internal import *
File "C:\Users\Firas\AppData\Local\Programs\Python\Python38-32\lib\site-packages\tensorflow\python\pywrap_tensorflow_internal.py", line 28, in
_pywrap_tensorflow_internal = swig_import_helper()
File "C:\Users\Firas\AppData\Local\Programs\Python\Python38-32\lib\site-packages\tensorflow\python\pywrap_tensorflow_internal.py", line 20, in swig_import_helper
import _pywrap_tensorflow_internal
ModuleNotFoundError: No module named '_pywrap_tensorflow_internal'

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
above this error message when asking for help.

any idea?

I too have the same problem. Can anyone solve this issue?

@Dharanya-Subramanian
Copy link

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
exec(code_obj, self.user_global_ns, self.user_ns)

File "", line 1, in
import tensorflow as tf

File "c:\users\elcot\anaconda3\envs'virtual_env'\lib\site-packages\tensorflow_init_.py", line 101, in
from tensorflow_core import *

File "c:\users\elcot\anaconda3\envs'virtual_env'\lib\site-packages\tensorflow_core_init_.py", line 46, in
from . _api.v2 import compat

File "c:\users\elcot\anaconda3\envs'virtual_env'\lib\site-packages\tensorflow_core_api\v2\compat_init_.py", line 39, in
from . import v1

File "c:\users\elcot\anaconda3\envs'virtual_env'\lib\site-packages\tensorflow_core_api\v2\compat\v1_init_.py", line 32, in
from . import compat

File "c:\users\elcot\anaconda3\envs'virtual_env'\lib\site-packages\tensorflow_core_api\v2\compat\v1\compat_init_.py", line 39, in
from . import v1

File "c:\users\elcot\anaconda3\envs'virtual_env'\lib\site-packages\tensorflow_core_api\v2\compat\v1\compat\v1_init_.py", line 29, in
from tensorflow._api.v2.compat.v1 import app

File "c:\users\elcot\anaconda3\envs'virtual_env'\lib\site-packages\tensorflow_core_api\v2\compat_init_.py", line 39, in
from . import v1

File "c:\users\elcot\anaconda3\envs'virtual_env'\lib\site-packages\tensorflow_core_api\v2\compat\v1_init_.py", line 32, in
from . import compat

File "c:\users\elcot\anaconda3\envs'virtual_env'\lib\site-packages\tensorflow_core_api\v2\compat\v1\compat_init_.py", line 39, in
from . import v1

File "c:\users\elcot\anaconda3\envs'virtual_env'\lib\site-packages\tensorflow_core_api\v2\compat\v1\compat\v1_init_.py", line 35, in
from tensorflow._api.v2.compat.v1 import debugging

File "c:\users\elcot\anaconda3\envs'virtual_env'\lib\site-packages\tensorflow_core_api\v2\compat\v1\debugging_init_.py", line 10, in
from . import experimental

File "c:\users\elcot\anaconda3\envs'virtual_env'\lib\site-packages\tensorflow_core_api\v2\compat\v1\debugging\experimental_init_.py", line 10, in
from tensorflow.python.debug.lib.dumping_callback import disable_dump_debug_info

File "c:\users\elcot\anaconda3\envs'virtual_env'\lib\site-packages\tensorflow_core\python\debug\lib\dumping_callback.py", line 29, in
from tensorflow.python.debug.lib import debug_events_writer

File "c:\users\elcot\anaconda3\envs'virtual_env'\lib\site-packages\tensorflow_core\python\debug\lib\debug_events_writer.py", line 24, in
from tensorflow.python import _pywrap_debug_events_writer

File "", line 1020, in _handle_fromlist

File "c:\users\elcot\anaconda3\envs'virtual_env'\lib\site-packages\tensorflow_init_.py", line 50, in getattr
module = self._load()

File "c:\users\elcot\anaconda3\envs'virtual_env'\lib\site-packages\tensorflow_init_.py", line 44, in _load
module = _importlib.import_module(self.name)

File "c:\users\elcot\anaconda3\envs'virtual_env'\lib\importlib_init_.py", line 126, in import_module
return _bootstrap._gcd_import(name[level:], package, level)

File "c:\users\elcot\anaconda3\envs'virtual_env'\lib\site-packages\tensorflow_core\python_init_.py", line 95, in
from tensorflow.python import keras

File "c:\users\elcot\anaconda3\envs'virtual_env'\lib\site-packages\tensorflow_core\python\keras_init_.py", line 27, in
from tensorflow.python.keras import models

File "c:\users\elcot\anaconda3\envs'virtual_env'\lib\site-packages\tensorflow_core\python\keras_init_.py", line 27, in
from tensorflow.python.keras import models

File "c:\users\elcot\anaconda3\envs'virtual_env'\lib\site-packages\tensorflow_core\python\keras\models.py", line 26, in
from tensorflow.python.keras.engine import sequential

File "c:\users\elcot\anaconda3\envs'virtual_env'\lib\site-packages\tensorflow_core\python\keras\engine\sequential.py", line 28, in
from tensorflow.python.keras.engine import training

File "c:\users\elcot\anaconda3\envs'virtual_env'\lib\site-packages\tensorflow_core\python\keras\engine\training.py", line 46, in
from tensorflow.python.keras.engine import training_arrays

File "c:\users\elcot\anaconda3\envs'virtual_env'\lib\site-packages\tensorflow_core\python\keras\engine\training_arrays.py", line 41, in
from scipy.sparse import issparse # pylint: disable=g-import-not-at-top

File "c:\users\elcot\anaconda3\envs'virtual_env'\lib\site-packages\scipy_init_.py", line 131, in
from scipy.config import show as show_config

File "c:\users\elcot\anaconda3\envs'virtual_env'\lib\site-packages\scipy_config_.py", line 13
lapack_mkl_info={'libraries': ['mkl_rt'], 'library_dirs': ['C:/Users/elcot/Anaconda3/envs/'virtual_env'\Library\lib'], 'define_macros': [('SCIPY_MKL_H', None), ('HAVE_CBLAS', None)], 'include_dirs': ['C:\Program Files (x86)\IntelSWTools\compilers_and_libraries_2019.0.117\windows\mkl', 'C:\Program Files (x86)\IntelSWTools\compilers_and_libraries_2019.0.117\windows\mkl\include', 'C:\Program Files (x86)\IntelSWTools\compilers_and_libraries_2019.0.117\windows\mkl\lib', 'C:/Users/elcot/Anaconda3/envs/'virtual_env'\Library\include']}
^
SyntaxError: invalid syntax

Can anyone help me out with this issue?

@Ozzey
Copy link

Ozzey commented Apr 19, 2021

after changing async to async1 i got the next error 👍 Using TensorFlow backend.
Traceback (most recent call last):
File "C:\Users\Firas\AppData\Local\Programs\Python\Python38-32\lib\site-packages\tensorflow\python\pywrap_tensorflow_internal.py", line 18, in swig_import_helper
fp, pathname, description = imp.find_module('_pywrap_tensorflow_internal', [dirname(file)])
File "C:\Users\Firas\AppData\Local\Programs\Python\Python38-32\lib\imp.py", line 296, in find_module
raise ImportError(_ERR_MSG.format(name), name=name)
ImportError: No module named '_pywrap_tensorflow_internal'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "C:\Users\Firas\AppData\Local\Programs\Python\Python38-32\lib\site-packages\tensorflow\python\pywrap_tensorflow.py", line 58, in
from tensorflow.python.pywrap_tensorflow_internal import *
File "C:\Users\Firas\AppData\Local\Programs\Python\Python38-32\lib\site-packages\tensorflow\python\pywrap_tensorflow_internal.py", line 28, in
_pywrap_tensorflow_internal = swig_import_helper()
File "C:\Users\Firas\AppData\Local\Programs\Python\Python38-32\lib\site-packages\tensorflow\python\pywrap_tensorflow_internal.py", line 20, in swig_import_helper
import _pywrap_tensorflow_internal
ModuleNotFoundError: No module named '_pywrap_tensorflow_internal'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "C:/Users/Firas/Desktop/f8.py", line 1, in
from keras.datasets import mnist
File "C:\Users\Firas\AppData\Local\Programs\Python\Python38-32\lib\site-packages\keras__init__.py", line 3, in
from . import utils
File "C:\Users\Firas\AppData\Local\Programs\Python\Python38-32\lib\site-packages\keras\utils__init__.py", line 6, in
from . import conv_utils
File "C:\Users\Firas\AppData\Local\Programs\Python\Python38-32\lib\site-packages\keras\utils\conv_utils.py", line 9, in
from .. import backend as K
File "C:\Users\Firas\AppData\Local\Programs\Python\Python38-32\lib\site-packages\keras\backend__init__.py", line 1, in
from .load_backend import epsilon
File "C:\Users\Firas\AppData\Local\Programs\Python\Python38-32\lib\site-packages\keras\backend\load_backend.py", line 90, in
from .tensorflow_backend import *
File "C:\Users\Firas\AppData\Local\Programs\Python\Python38-32\lib\site-packages\keras\backend\tensorflow_backend.py", line 5, in
import tensorflow as tf
File "C:\Users\Firas\AppData\Local\Programs\Python\Python38-32\lib\site-packages\tensorflow__init__.py", line 24, in
from tensorflow.python import pywrap_tensorflow # pylint: disable=unused-import
File "C:\Users\Firas\AppData\Local\Programs\Python\Python38-32\lib\site-packages\tensorflow\python__init__.py", line 49, in
from tensorflow.python import pywrap_tensorflow
File "C:\Users\Firas\AppData\Local\Programs\Python\Python38-32\lib\site-packages\tensorflow\python\pywrap_tensorflow.py", line 74, in
raise ImportError(msg)
ImportError: Traceback (most recent call last):
File "C:\Users\Firas\AppData\Local\Programs\Python\Python38-32\lib\site-packages\tensorflow\python\pywrap_tensorflow_internal.py", line 18, in swig_import_helper
fp, pathname, description = imp.find_module('_pywrap_tensorflow_internal', [dirname(file)])
File "C:\Users\Firas\AppData\Local\Programs\Python\Python38-32\lib\imp.py", line 296, in find_module
raise ImportError(_ERR_MSG.format(name), name=name)
ImportError: No module named '_pywrap_tensorflow_internal'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "C:\Users\Firas\AppData\Local\Programs\Python\Python38-32\lib\site-packages\tensorflow\python\pywrap_tensorflow.py", line 58, in
from tensorflow.python.pywrap_tensorflow_internal import *
File "C:\Users\Firas\AppData\Local\Programs\Python\Python38-32\lib\site-packages\tensorflow\python\pywrap_tensorflow_internal.py", line 28, in
_pywrap_tensorflow_internal = swig_import_helper()
File "C:\Users\Firas\AppData\Local\Programs\Python\Python38-32\lib\site-packages\tensorflow\python\pywrap_tensorflow_internal.py", line 20, in swig_import_helper
import _pywrap_tensorflow_internal
ModuleNotFoundError: No module named '_pywrap_tensorflow_internal'

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
above this error message when asking for help.

any idea?

So after changing async to async1 , I am also facing the same problem
"ModuleNotFoundError: No module named '_pywrap_tensorflow_internal'"

Any solution?

Python 3.9.2

@Ozzey
Copy link

Ozzey commented Apr 22, 2021 via email

@9609275256088
Copy link

File C:\ProgramData\Anaconda3\lib\site-packages\tensorflow\python\pywrap_tensorflow_internal.py:114
def TFE_ContextOptionsSetAsync(arg1, async):

@jafarliu
Copy link

did any one resolve import error issue?
Screen Shot 2023-02-14 at 12 15 41 AM

@ngjunlong9651
Copy link

did any one resolve import error issue? Screen Shot 2023-02-14 at 12 15 41 AM

I have this issue as well. Even after changing the async -> async1

@Madhukar7559
Copy link

did any one resolve import error issue? Screen Shot 2023-02-14 at 12 15 41 AM

I have this issue as well. Even after changing the async -> async1

Is the issue Solved ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
stat:awaiting tensorflower Status - Awaiting response from tensorflower
Projects
None yet
Development

No branches or pull requests