I am using
Python 3.8.7
pip 20.2.3
Windows 10 64bit
CPU Intel Pentium G4400
and when I import tensorflow as tf on the Python IDLE ( that comes with Python when installing it ) , it shows the below error :
Traceback (most recent call last):
File "C:\Users\User\AppData\Local\Programs\Python\Python38\lib\site-packages\tensorflow\python\pywrap_tensorflow.py", line 64, in <module>
from tensorflow.python._pywrap_tensorflow_internal import *
ImportError: DLL load failed while importing _pywrap_tensorflow_internal: 動態連結程式庫 (DLL) 初始化例行程序失敗。
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "C:\Python\Python__MyFinalProject__ML\TensorFlow.py", line 3, in <module>
import tensorflow
File "C:\Users\User\AppData\Local\Programs\Python\Python38\lib\site-packages\tensorflow\__init__.py", line 41, in <module>
from tensorflow.python.tools import module_util as _module_util
File "C:\Users\User\AppData\Local\Programs\Python\Python38\lib\site-packages\tensorflow\python\__init__.py", line 39, in <module>
from tensorflow.python import pywrap_tensorflow as _pywrap_tensorflow
File "C:\Users\User\AppData\Local\Programs\Python\Python38\lib\site-packages\tensorflow\python\pywrap_tensorflow.py", line 83, in <module>
raise ImportError(msg)
ImportError: Traceback (most recent call last):
File "C:\Users\User\AppData\Local\Programs\Python\Python38\lib\site-packages\tensorflow\python\pywrap_tensorflow.py", line 64, in <module>
from tensorflow.python._pywrap_tensorflow_internal import *
ImportError: DLL load failed while importing _pywrap_tensorflow_internal: 動態連結程式庫 (DLL) 初始化例行程序失敗。
Failed to load the native TensorFlow runtime.
See https://www.tensorflow.org/install/errors
I tried download the VS and included the C++ package in the VS installer. But still can’t fix this problem : (
Can anyone please help 🙏🏻
And I'm sorry that there are some traditional Chinese characters and I google translate it : "動態連結程式庫 (DLL) 初始化例行程序失敗。" --> "The dynamic link library (DLL) initialization routine failed."
Edit
Just came up with a solution : is that my PC's CPU is too old that some instructions ( e.g. AVX support ) required by tensorflow are missing.
I've tried to find a work-around like intel sde. But I would like to suggest that , don't waste time on that , just replace a new CPU or buy a new PC. Save your time ! : )
The workaround is to simply install Microsoft Visual C++ 2015 Redistributable 64 bits. This way, the DLL is installed in system32 folder and the bug can be rectified.
Related
I installed Tensorflow through pip install and it was successful but when i try to use it I have this ImportError:
Traceback (most recent call last):
File "C:\Users\AKIN\AppData\Local\Programs\Python\Python38\lib\site-packages\tensorflow\python\pywrap_tensorflow.py", line 64, 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 "C:/Users/AKIN/PythonProjects/sample_codes/trial_tf.py", line 2, in <module>
import tensorflow as tf
File "C:\Users\AKIN\AppData\Local\Programs\Python\Python38\lib\site-packages\tensorflow\__init__.py", line 41, in <module>
from tensorflow.python.tools import module_util as _module_util
File "C:\Users\AKIN\AppData\Local\Programs\Python\Python38\lib\site-packages\tensorflow\python\__init__.py", line 39, in <module>
from tensorflow.python import pywrap_tensorflow as _pywrap_tensorflow
File "C:\Users\AKIN\AppData\Local\Programs\Python\Python38\lib\site-packages\tensorflow\python\pywrap_tensorflow.py", line 83, in <module>
raise ImportError(msg)
ImportError: Traceback (most recent call last):
File "C:\Users\AKIN\AppData\Local\Programs\Python\Python38\lib\site-packages\tensorflow\python\pywrap_tensorflow.py", line 64, 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.
I have checked this and I have seen Windows build failing but I don't know if that's what affecting it:
https://github.com/tensorflow/tensorflow
What is going on?
After hundreds of Google searches and Youtube videos, I found the solution to this problem about a month ago. Unlike other third-party modules in python (e.g. Pandas, Matplotlib, etc.)- which require pip install - there are a different set of steps including installing NVIDIA with a Cuda-enabled GPU or CPU (Tensorflow works with either one) and activating a cond environment.
One youtube video I found to be particularly useful briefly explains each step to installing tensorflow without a DLL error. Here is the link: https://www.youtube.com/watch?v=5Ym-dOS9ssA&t=327s
The instructor uses Pycharm, but I am sure you can easily follow each step with another IDE.
If you have any questions or want clarification, please do not hesitate to ask. Best of luck! :)
I'm new at python (version of python 3.7.7) and I'm trying to run a finished project, I imported everything but tensorflow is not working the error is shown down below:
Traceback (most recent call last): File
"C:\Users\User\AppData\Local\Programs\Python\Python37\lib\site-packages\tensorflow\python\pywrap_tensorflow.py",
line 64, in <module>
from tensorflow.python._pywrap_tensorflow_internal import * ImportError: DLL load failed: A dynamic link library (DLL)
initialization routine failed. During handling of the above exception,
another exception occurred: Traceback (most recent call last): File
"C:/Users/User/Desktop/adsp/train.py", line 1, in <module>
import tensorflow as tf File "C:\Users\User\AppData\Local\Programs\Python\Python37\lib\site-packages\tensorflow\__init__.py",
line 41, in <module>
from tensorflow.python.tools import module_util as _module_util File
"C:\Users\User\AppData\Local\Programs\Python\Python37\lib\site-packages\tensorflow\python\__init__.py",
line 39, in <module>
from tensorflow.python import pywrap_tensorflow as _pywrap_tensorflow File "C:\Users\User\AppData\Local\Programs\Python\Python37\lib\site-packages\tensorflow\python\pywrap_tensorflow.py",
line 83, in <module>
raise ImportError(msg) ImportError: Traceback (most recent call last): File
"C:\Users\User\AppData\Local\Programs\Python\Python37\lib\site-packages\tensorflow\python\pywrap_tensorflow.py",
line 64, in <module>
from tensorflow.python._pywrap_tensorflow_internal import * ImportError: DLL load failed: 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
reasons and solutions. Include the entire stack trace above this
error message when asking for help.
The issue is of compatibility. The version of tensorflow which you are trying to run with python 3.7 is not compatible with the same. In order to check for possible compatible versions please visit this link.
Also in case you are facing too many issues while trying to install some library in python and your work is getting held, I'd recommend you to make use of Google Colab.
There you won't need to worry about installation of packages. Although one must experience the installation and setup of packages as a learning.
Try uninstalling tensorflow from pip and reinstalling it again. It seems you have an import error. Also if you have two or more Python versions on your machine, this can cause issues sometimes
I've looked through previous answers to similar questions but couldn't find the answer that worked for me.
I've worked with TensorFlow for a long time. Currently trying out Yolov4 which has a requirement to use Tensorflow version 2.3.0, so I decided to install that one.
Anaconda's latest release is 2.1.0 that works great on my computer. So since that was not enough, I created a new environment and installed Tensorflow with pip install tensorflow-gpu which installs version 2.3.0 seemingly without errors.
Then for the import tensorflow as tf I get this error. Any ideas what to try to resolve this?
>>> import tensorflow as tf
Traceback (most recent call last):
File "C:\Users\mazat\Anaconda3\envs\tf23\lib\site-packages\tensorflow\python\pywrap_tensorflow.py", line 64, in <module>
from tensorflow.python._pywrap_tensorflow_internal import *
ImportError: DLL load failed: The specified module could not be found.
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "C:\Users\mazat\Anaconda3\envs\tf23\lib\site-packages\tensorflow\__init__.py", line 41, in <module>
from tensorflow.python.tools import module_util as _module_util
File "C:\Users\mazat\Anaconda3\envs\tf23\lib\site-packages\tensorflow\python\__init__.py", line 40, in <module>
from tensorflow.python.eager import context
File "C:\Users\mazat\Anaconda3\envs\tf23\lib\site-packages\tensorflow\python\eager\context.py", line 35, in <module>
from tensorflow.python import pywrap_tfe
File "C:\Users\mazat\Anaconda3\envs\tf23\lib\site-packages\tensorflow\python\pywrap_tfe.py", line 28, in <module>
from tensorflow.python import pywrap_tensorflow
File "C:\Users\mazat\Anaconda3\envs\tf23\lib\site-packages\tensorflow\python\pywrap_tensorflow.py", line 83, in <module>
raise ImportError(msg)
ImportError: Traceback (most recent call last):
File "C:\Users\mazat\Anaconda3\envs\tf23\lib\site-packages\tensorflow\python\pywrap_tensorflow.py", line 64, in <module>
from tensorflow.python._pywrap_tensorflow_internal import *
ImportError: DLL load failed: The specified module could not be found.
Looks like the problem was the old version of Redistributable for Visual Studio.
With the new version from here, it seems to work thus far!
https://support.microsoft.com/en-us/help/2977003/the-latest-supported-visual-c-downloads
I had a similar problem and update Visual Studio (https://visualstudio.microsoft.com/pt-br/downloads/) worked for me.
I'm trying to run I program I've written for Tensorflow from a file in Notepad using Powershell. Whenever I run python main.py to open and execute the code, I get the error below.
I haven't really found anything to try, and the only thing I felt I could do is uninstall and re-install Tensorflow, but that isn't working.
C:\Users\stxrsstillfade> cd tensorflow-demo
C:\Users\stxrsstillfade\tensorflow-demo> python main.py
The code error isn't even with the code. The traceback is saying that the problem is with the first line, import tensorflow.
Traceback (most recent call last):
File "main.py", line 1, in <module>
import tensorflow as tf
File "C:\Python27\lib\site-packages\tensorflow\__init__.py", line 24, in <module>
from tensorflow.python import *
File "C:\Python27\lib\site-packages\tensorflow\python\__init__.py", line 72, in <module>
raise ImportError(msg)
ImportError: Traceback (most recent call last):
File "C:\Python27\lib\site-packages\tensorflow\python\__init__.py", line 66, in <module>
from tensorflow.python import pywrap_tensorflow
File "C:\Python27\lib\site-packages\tensorflow\python\pywrap_tensorflow.py", line 28, in <module>
_pywrap_tensorflow = swig_import_helper()
File "C:\Python27\lib\site-packages\tensorflow\python\pywrap_tensorflow.py", line 20, in swig_import_helper
import _pywrap_tensorflow
ImportError: No module named _pywrap_tensorflow
Failed to load the native TensorFlow runtime.
See https://github.com/tensorflow/tensorflow/blob/master/tensorflow/g3doc/get_started/os_setup.md#import_error
for some common reasons and solutions. Include the entire stack trace
above this error message when asking for help.
I've tried getting to the GitHub link, but it seems to have been deleted.
Thank you for your answer in advance.
Please follow the instructions from TensorFlow website. I recommend please install Tensorflow 2, if you are using lower versions.
To fix Failed to load the native TensorFlow runtime, you need to download and install/update the Microsoft Visual C++ 2015-2019 Redistributable (x64) from here.
If you are facing any other issues possible reasons are
Your CPU does not support AVX2 instructions
Your CPU/Python is on 32 bits
There is a library that is in a different location/not installed on your system that cannot be loaded.
Please refer tested build configurations for windows CPU and GPU.
I started compiling TensorFlow from source on Ubuntu Linux 16.06 LTS, running the commands from the TensorFlow Linux compilation instructions.
My CUDA and CuDNN setup works, as the pre-compiled TensorFlow nvidia-docker image works.
After using bazel to build the TensorFlow Python wheel, and then installing the wheel with pip, I get the following error message when trying to import TensorFlow:
>>> import tensorflow
Traceback (most recent call last):
File "/home/james/workspace/tensorflow/tensorflow/python/pywrap_tensorflow.py", line 41, in <module>
from tensorflow.python.pywrap_tensorflow_internal import *
ImportError: No module named 'tensorflow.python.pywrap_tensorflow_internal'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/home/james/workspace/tensorflow/tensorflow/__init__.py", line 24, in <module>
from tensorflow.python import *
File "/home/james/workspace/tensorflow/tensorflow/python/__init__.py", line 49, in <module>
from tensorflow.python import pywrap_tensorflow
File "/home/james/workspace/tensorflow/tensorflow/python/pywrap_tensorflow.py", line 52, in <module>
raise ImportError(msg)
ImportError: Traceback (most recent call last):
File "/home/james/workspace/tensorflow/tensorflow/python/pywrap_tensorflow.py", line 41, in <module>
from tensorflow.python.pywrap_tensorflow_internal import *
ImportError: No module named 'tensorflow.python.pywrap_tensorflow_internal'
Failed to load the native TensorFlow runtime.
See https://www.tensorflow.org/install/install_sources#common_installation_problems
This error happens when you are running Python from the TensorFlow source directory after having installed the Python wheel.
A similar error happens when you try importing TensorFlow before installing the Python wheel.
The solution to this problem is to change your working directory to something else, while still remaining in the virtualenv that you installed the Python wheel to.