这是indexloc提供的服务,不要输入任何密码
Skip to content

Error in loading Tensorflow in python #97345

@AbhimanyuChatterjee

Description

@AbhimanyuChatterjee

Issue type

Bug

Have you reproduced the bug with TensorFlow Nightly?

Yes

Source

source

TensorFlow version

tensorflow-cpu-2.19.0

Custom code

Yes

OS platform and distribution

Windows 11

Mobile device

No response

Python version

Python 3.12.10

Bazel version

No response

GCC/compiler version

No response

CUDA/cuDNN version

No response

GPU model and memory

No response

Current behavior?

import tensorflow as tf produces the following message:

**import tensorflow as tf
[autoreload of tensorflow.python failed: Traceback (most recent call last):
File "C:\Users\AbhimanyuChatterjee\AppData\Local\Programs\Python\Python312\Lib\site-packages\IPython\extensions\autoreload.py", line 276, in check
superreload(m, reload, self.old_objects)
File "C:\Users\AbhimanyuChatterjee\AppData\Local\Programs\Python\Python312\Lib\site-packages\IPython\extensions\autoreload.py", line 475, in superreload
module = reload(module)
^^^^^^^^^^^^^^
File "C:\Users\AbhimanyuChatterjee\AppData\Local\Programs\Python\Python312\Lib\importlib_init_.py", line 121, in reload
raise ImportError(f"parent {parent_name!r} not in sys.modules",
ImportError: parent 'tensorflow' not in sys.modules
]
[autoreload of tensorflow.python.platform.self_check failed: Traceback (most recent call last):
File "C:\Users\AbhimanyuChatterjee\AppData\Local\Programs\Python\Python312\Lib\site-packages\IPython\extensions\autoreload.py", line 276, in check
superreload(m, reload, self.old_objects)
File "C:\Users\AbhimanyuChatterjee\AppData\Local\Programs\Python\Python312\Lib\site-packages\IPython\extensions\autoreload.py", line 475, in superreload
module = reload(module)
^^^^^^^^^^^^^^
File "C:\Users\AbhimanyuChatterjee\AppData\Local\Programs\Python\Python312\Lib\importlib_init_.py", line 131, in reload
_bootstrap._exec(spec, module)
File "", line 866, in _exec
File "", line 999, in exec_module
File "", line 488, in call_with_frames_removed
File "C:\Users\AbhimanyuChatterjee\AppData\Local\Programs\Python\Python312\Lib\site-packages\tensorflow\python\platform\self_check.py", line 23, in
from tensorflow.python.platform import build_info
File "C:\Users\AbhimanyuChatterjee\AppData\Local\Programs\Python\Python312\Lib\site-packages\tensorflow_init
.py", line 40, in
from tensorflow.python import pywrap_tensorflow as _pywrap_tensorflow # pylint: disable=unused-import
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\AbhimanyuChatterjee\AppData\Local\Programs\Python\Python312\Lib\site-packages\tensorflow\python\pywrap_tensorflow.py", line 37, in
self_check.preload_check()
^^^^^^^^^^^^^^^^^^^^^^^^
AttributeError: module 'tensorflow.python.platform.self_check' has no attribute 'preload_check'
]

ImportError Traceback (most recent call last)
File ~\AppData\Local\Programs\Python\Python312\Lib\site-packages\tensorflow\python\pywrap_tensorflow.py:73
72 try:
---> 73 from tensorflow.python._pywrap_tensorflow_internal import *
74 # This try catch logic is because there is no bazel equivalent for py_extension.
75 # Externally in opensource we must enable exceptions to load the shared object
76 # by exposing the PyInit symbols with pybind. This error will only be
77 # caught internally or if someone changes the name of the target _pywrap_tensorflow_internal.
78
79 # This logic is used in other internal projects using py_extension.

ImportError: DLL load failed while importing _pywrap_tensorflow_internal: A dynamic link library (DLL) initialization routine failed.

During handling of the above exception, another exception occurred:

ImportError Traceback (most recent call last)
Cell In[8], line 1
----> 1 import tensorflow as tf

File ~\AppData\Local\Programs\Python\Python312\Lib\site-packages\tensorflow_init_.py:40
37 _os.environ.setdefault("ENABLE_RUNTIME_UPTIME_TELEMETRY", "1")
39 # Do not remove this line; See #42596
---> 40 from tensorflow.python import pywrap_tensorflow as _pywrap_tensorflow # pylint: disable=unused-import
41 from tensorflow.python.tools import module_util as _module_util
42 from tensorflow.python.util.lazy_loader import KerasLazyLoader as _KerasLazyLoader

File ~\AppData\Local\Programs\Python\Python312\Lib\site-packages\tensorflow\python\pywrap_tensorflow.py:88
86 sys.setdlopenflags(_default_dlopen_flags)
87 except ImportError:
---> 88 raise ImportError(
89 f'{traceback.format_exc()}'
90 f'\n\nFailed to load the native TensorFlow runtime.\n'
91 f'See https://www.tensorflow.org/install/errors '
92 f'for some common causes and solutions.\n'
93 f'If you need help, create an issue '
94 f'at https://github.com/tensorflow/tensorflow/issues '
95 f'and include the entire stack trace above this error message.')
97 # pylint: enable=wildcard-import,g-import-not-at-top,unused-import,line-too-long

ImportError: Traceback (most recent call last):
File "C:\Users\AbhimanyuChatterjee\AppData\Local\Programs\Python\Python312\Lib\site-packages\tensorflow\python\pywrap_tensorflow.py", line 73, in
from tensorflow.python._pywrap_tensorflow_internal import *
ImportError: DLL load failed while importing _pywrap_tensorflow_internal: A dynamic link library (DLL) initialization routine failed.

Failed to load the native TensorFlow runtime.
See https://www.tensorflow.org/install/errors for some common causes and solutions.
If you need help, create an issue at https://github.com/tensorflow/tensorflow/issues and include the entire stack trace above this error message.**

Standalone code to reproduce the issue

import tensorflow as tf
[autoreload of tensorflow.python failed: Traceback (most recent call last):
  File "C:\Users\AbhimanyuChatterjee\AppData\Local\Programs\Python\Python312\Lib\site-packages\IPython\extensions\autoreload.py", line 276, in check
    superreload(m, reload, self.old_objects)
  File "C:\Users\AbhimanyuChatterjee\AppData\Local\Programs\Python\Python312\Lib\site-packages\IPython\extensions\autoreload.py", line 475, in superreload
    module = reload(module)
             ^^^^^^^^^^^^^^
  File "C:\Users\AbhimanyuChatterjee\AppData\Local\Programs\Python\Python312\Lib\importlib\__init__.py", line 121, in reload
    raise ImportError(f"parent {parent_name!r} not in sys.modules",
ImportError: parent 'tensorflow' not in sys.modules
]
[autoreload of tensorflow.python.platform.self_check failed: Traceback (most recent call last):
  File "C:\Users\AbhimanyuChatterjee\AppData\Local\Programs\Python\Python312\Lib\site-packages\IPython\extensions\autoreload.py", line 276, in check
    superreload(m, reload, self.old_objects)
  File "C:\Users\AbhimanyuChatterjee\AppData\Local\Programs\Python\Python312\Lib\site-packages\IPython\extensions\autoreload.py", line 475, in superreload
    module = reload(module)
             ^^^^^^^^^^^^^^
  File "C:\Users\AbhimanyuChatterjee\AppData\Local\Programs\Python\Python312\Lib\importlib\__init__.py", line 131, in reload
    _bootstrap._exec(spec, module)
  File "<frozen importlib._bootstrap>", line 866, in _exec
  File "<frozen importlib._bootstrap_external>", line 999, in exec_module
  File "<frozen importlib._bootstrap>", line 488, in _call_with_frames_removed
  File "C:\Users\AbhimanyuChatterjee\AppData\Local\Programs\Python\Python312\Lib\site-packages\tensorflow\python\platform\self_check.py", line 23, in <module>
    from tensorflow.python.platform import build_info
  File "C:\Users\AbhimanyuChatterjee\AppData\Local\Programs\Python\Python312\Lib\site-packages\tensorflow\__init__.py", line 40, in <module>
    from tensorflow.python import pywrap_tensorflow as _pywrap_tensorflow  # pylint: disable=unused-import
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\AbhimanyuChatterjee\AppData\Local\Programs\Python\Python312\Lib\site-packages\tensorflow\python\pywrap_tensorflow.py", line 37, in <module>
    self_check.preload_check()
    ^^^^^^^^^^^^^^^^^^^^^^^^
AttributeError: module 'tensorflow.python.platform.self_check' has no attribute 'preload_check'
]
---------------------------------------------------------------------------
ImportError                               Traceback (most recent call last)
File ~\AppData\Local\Programs\Python\Python312\Lib\site-packages\tensorflow\python\pywrap_tensorflow.py:73
     72 try:
---> 73   from tensorflow.python._pywrap_tensorflow_internal import *
     74 # This try catch logic is because there is no bazel equivalent for py_extension.
     75 # Externally in opensource we must enable exceptions to load the shared object
     76 # by exposing the PyInit symbols with pybind. This error will only be
     77 # caught internally or if someone changes the name of the target _pywrap_tensorflow_internal.
     78 
     79 # This logic is used in other internal projects using py_extension.

ImportError: DLL load failed while importing _pywrap_tensorflow_internal: A dynamic link library (DLL) initialization routine failed.

During handling of the above exception, another exception occurred:

ImportError                               Traceback (most recent call last)
Cell In[8], line 1
----> 1 import tensorflow as tf

File ~\AppData\Local\Programs\Python\Python312\Lib\site-packages\tensorflow\__init__.py:40
     37 _os.environ.setdefault("ENABLE_RUNTIME_UPTIME_TELEMETRY", "1")
     39 # Do not remove this line; See https://github.com/tensorflow/tensorflow/issues/42596
---> 40 from tensorflow.python import pywrap_tensorflow as _pywrap_tensorflow  # pylint: disable=unused-import
     41 from tensorflow.python.tools import module_util as _module_util
     42 from tensorflow.python.util.lazy_loader import KerasLazyLoader as _KerasLazyLoader

File ~\AppData\Local\Programs\Python\Python312\Lib\site-packages\tensorflow\python\pywrap_tensorflow.py:88
     86     sys.setdlopenflags(_default_dlopen_flags)
     87 except ImportError:
---> 88   raise ImportError(
     89       f'{traceback.format_exc()}'
     90       f'\n\nFailed to load the native TensorFlow runtime.\n'
     91       f'See https://www.tensorflow.org/install/errors '
     92       f'for some common causes and solutions.\n'
     93       f'If you need help, create an issue '
     94       f'at https://github.com/tensorflow/tensorflow/issues '
     95       f'and include the entire stack trace above this error message.')
     97 # pylint: enable=wildcard-import,g-import-not-at-top,unused-import,line-too-long

ImportError: Traceback (most recent call last):
  File "C:\Users\AbhimanyuChatterjee\AppData\Local\Programs\Python\Python312\Lib\site-packages\tensorflow\python\pywrap_tensorflow.py", line 73, in <module>
    from tensorflow.python._pywrap_tensorflow_internal import *
ImportError: DLL load failed while importing _pywrap_tensorflow_internal: A dynamic link library (DLL) initialization routine failed.


Failed to load the native TensorFlow runtime.
See https://www.tensorflow.org/install/errors for some common causes and solutions.
If you need help, create an issue at https://github.com/tensorflow/tensorflow/issues and include the entire stack trace above this error message.

Relevant log output

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions