tensorflow: Tensorflow Import Not working

Issue type

Support

Have you reproduced the bug with TensorFlow Nightly?

Yes

Source

source

TensorFlow version

tf 2.17.0

Custom code

Yes

OS platform and distribution

Windows 11 Home (Version 23H2, OS Build 22631.4169)

Mobile device

No response

Python version

Error was reproduced on py 3.12.0 and py 3.11.9

Bazel version

No response

GCC/compiler version

No response

CUDA/cuDNN version

No response

GPU model and memory

No response

Current behavior?

I expected tensorflow to import as normal, but the terminal throws the same error every time. I’ve uninstalled + reinstalled Python (3.12.0 and 3.11.9 seperately, since the documentation said that tensorflow was supported up till py 3.11) multiple times, and done the same with tensorflow, tried the same thing with tf-nightly too.

Standalone code to reproduce the issue

import tensorflow as tf

Relevant log output

Traceback (most recent call last):
  File "C:\Users\khiza\AppData\Local\Programs\Python\Python311\Lib\site-packages\tensorflow\python\pywrap_tensorflow.py", line 70, 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.

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "C:\Users\khiza\AppData\Local\Programs\Python\Python311\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\khiza\AppData\Local\Programs\Python\Python311\Lib\site-packages\tensorflow\python\pywrap_tensorflow.py", line 85, in <module>
    raise ImportError(
ImportError: Traceback (most recent call last):
  File "C:\Users\khiza\AppData\Local\Programs\Python\Python311\Lib\site-packages\tensorflow\python\pywrap_tensorflow.py", line 70, 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.

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Comments: 61 (21 by maintainers)

Most upvoted comments

Thank you for the link to the original issue @mihaimaruseac. Sorry about the shortcomings in mentioning my errors with importing the library, and I will keep them in mind for the future. Have a great day, the both of you, and thank you @mraunak for guiding me through solving this problem to the best of your ability.

Thank you very much @mihaimaruseac, yeah sure, I will take care of the points mentioned

Hi @NexusHex, Could you please download and install the Python package in a new location, somewhere on the C:\ drive? I’m a bit puzzled since it’s working fine on my end without needing any pip installation. I tried with the exact Python version that you have.

image

Hi @NexusHex can you please try the steps below and let us know if the issue persists image