I’m trying to set up TensorFlow in a conda environment on my Windows machine, but I’m encountering an ImportError related to _pywrap_tensorflow_internal. Here are the details of my setup and the error message I’m getting:
Environment:
OS: Windows
Python version: 3.8.15 (packaged by conda-forge)
TensorFlow version: 2.10
CPU only (no GPU)
Microsoft Visual C++ 2015 Redistributable is installed
Steps to reproduce:
Created a conda environment named tf_env
Installed TensorFlow using pip install tensorflow==2.10
Tried to import TensorFlow in Python
Error message:
(tf_env) C:UsersAli Ahmed>python –version
Python 3.8.15
(tf_env) C:UsersAli Ahmed>python
Python 3.8.15 | packaged by conda-forge | (default, Nov 22 2022, 08:43:00) [MSC v.1929 64 bit (AMD64)] on win32
Type “help”, “copyright”, “credits” or “license” for more information.
import tensorflow
Traceback (most recent call last):
File “C:Anacondaenvstf_envlibsite-packagestensorflowpythonpywrap_tensorflow.py”, line 62, 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.
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File “”, line 1, in
File “C:Anacondaenvstf_envlibsite-packagestensorflow_init_.py”, line 37, in
from tensorflow.python.tools import module_util as module_util
File “C:Anacondaenvstf_envlibsite-packagestensorflowpython_init.py”, line 36, in
from tensorflow.python import pywrap_tensorflow as _pywrap_tensorflow
File “C:Anacondaenvstf_envlibsite-packagestensorflowpythonpywrap_tensorflow.py”, line 77, in
raise ImportError(
ImportError: Traceback (most recent call last):
File “C:Anacondaenvstf_envlibsite-packagestensorflowpythonpywrap_tensorflow.py”, line 62, 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.