问题
I installed latest python 3.6.4 x64 version
and then installed tensorflow for cpu-only with pip3
C:\>pip3 install tensorflow
however when I tried to import tensorflow in python
it showed me the error below
I am sure that I have installed Microsoft Visual C++ 2015 Redistributable(x64)
so it wll not be the problem of dll msvcp140.dll lost
it say that "DLL load failed with error code -1073741795"
so what is exactly the problem here
i cannot find any other information about this error code
my os : windows 7 enterprise with service pack 1 / 64 bit / intel core i5 M 540
>>> import tensorflow
Traceback (most recent call last):
File "C:\Users\Alan\AppData\Local\Programs\Python\Python36\lib\site-packages\t
ensorflow\python\pywrap_tensorflow_internal.py", line 18, in swig_import_helper
return importlib.import_module(mname)
File "C:\Users\Alan\AppData\Local\Programs\Python\Python36\lib\importlib\__ini
t__.py", line 126, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 994, in _gcd_import
File "<frozen importlib._bootstrap>", line 971, in _find_and_load
File "<frozen importlib._bootstrap>", line 955, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 658, in _load_unlocked
File "<frozen importlib._bootstrap>", line 571, in module_from_spec
File "<frozen importlib._bootstrap_external>", line 922, in create_module
File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
ImportError: DLL load failed with error code -1073741795
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "C:\Users\Alan\AppData\Local\Programs\Python\Python36\lib\site-packages\t
ensorflow\python\pywrap_tensorflow.py", line 58, in <module>
from tensorflow.python.pywrap_tensorflow_internal import *
File "C:\Users\Alan\AppData\Local\Programs\Python\Python36\lib\site-packages\t
ensorflow\python\pywrap_tensorflow_internal.py", line 21, in <module>
_pywrap_tensorflow_internal = swig_import_helper()
File "C:\Users\Alan\AppData\Local\Programs\Python\Python36\lib\site-packages\t
ensorflow\python\pywrap_tensorflow_internal.py", line 20, in swig_import_helper
return importlib.import_module('_pywrap_tensorflow_internal')
File "C:\Users\Alan\AppData\Local\Programs\Python\Python36\lib\importlib\__ini
t__.py", line 126, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
ModuleNotFoundError: No module named '_pywrap_tensorflow_internal'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "C:\Users\Alan\AppData\Local\Programs\Python\Python36\lib\site-packages\t
ensorflow\__init__.py", line 24, in <module>
from tensorflow.python import *
File "C:\Users\Alan\AppData\Local\Programs\Python\Python36\lib\site-packages\t
ensorflow\python\__init__.py", line 49, in <module>
from tensorflow.python import pywrap_tensorflow
File "C:\Users\Alan\AppData\Local\Programs\Python\Python36\lib\site-packages\t
ensorflow\python\pywrap_tensorflow.py", line 74, in <module>
raise ImportError(msg)
ImportError: Traceback (most recent call last):
File "C:\Users\Alan\AppData\Local\Programs\Python\Python36\lib\site-packages\t
ensorflow\python\pywrap_tensorflow_internal.py", line 18, in swig_import_helper
return importlib.import_module(mname)
File "C:\Users\Alan\AppData\Local\Programs\Python\Python36\lib\importlib\__ini
t__.py", line 126, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 994, in _gcd_import
File "<frozen importlib._bootstrap>", line 971, in _find_and_load
File "<frozen importlib._bootstrap>", line 955, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 658, in _load_unlocked
File "<frozen importlib._bootstrap>", line 571, in module_from_spec
File "<frozen importlib._bootstrap_external>", line 922, in create_module
File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
ImportError: DLL load failed with error code -1073741795
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "C:\Users\Alan\AppData\Local\Programs\Python\Python36\lib\site-packages\t
ensorflow\python\pywrap_tensorflow.py", line 58, in <module>
from tensorflow.python.pywrap_tensorflow_internal import *
File "C:\Users\Alan\AppData\Local\Programs\Python\Python36\lib\site-packages\t
ensorflow\python\pywrap_tensorflow_internal.py", line 21, in <module>
_pywrap_tensorflow_internal = swig_import_helper()
File "C:\Users\Alan\AppData\Local\Programs\Python\Python36\lib\site-packages\t
ensorflow\python\pywrap_tensorflow_internal.py", line 20, in swig_import_helper
return importlib.import_module('_pywrap_tensorflow_internal')
File "C:\Users\Alan\AppData\Local\Programs\Python\Python36\lib\importlib\__ini
t__.py", line 126, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
ModuleNotFoundError: No module named '_pywrap_tensorflow_internal'
Failed to load the native TensorFlow runtime.
See https://www.tensorflow.org/install/install_sources#common_installation_probl
ems
for some common reasons and solutions. Include the entire stack trace
above this error message when asking for help.
回答1:
I got same problem with tensorflow1.6-CPU on win7 64bit(Intel Core 2 Duo Cpu T6670 2.2GHz)
After I found this, and it solved my problem.
Reference this issue: https://github.com/tensorflow/tensorflow/issues/17386
Re-installed by this tensorflow-1.6.0-cp36-cp36m-win_amd64.whl: https://github.com/fo40225/tensorflow-windows-wheel/tree/master/1.6.0/py36/CPU/sse2
Hope this .whl may help you.
回答2:
I faced the same issue with tensorflow-1.12.0 what i did was :
- Install anaconda
- open anaconda prompt
conda create -n tfp python=3.6
activate tfp
conda install tensorflow
python
- Now check by importing tensorflow
the version i used was 3.6, but you can also try with 3.7 Hope it helps!
回答3:
I downgraded tensorflow to 1.10.0 and it fixed the issue
回答4:
Probably, your CPU does not have the instructions for AVX (needed for all tensorflow binaries since 1.6). You can check that with some tool like CPU-Z. If that is the case, you can donwload the correct wheel here (use SSE2 binaries):
tensorflow-windows-wheel
回答5:
I had the same issue. I upgraded pip version with:
python -m pip install --upgrade pip
also, downgraded with
pip install tensorflow==2.0
and it worked
回答6:
ImportError: DLL load failed
for
windows 10
python 3.6
pip install protobuf==3.6.0
or
pip3 install protobuf==3.6.0
回答7:
I fixed it. Spend days searching to fix them.
Installed tensorflow with pip install tensorflow-cpu
Updated visual C++ 2015-2019
The issue was because I didn't have nvidia graphics so that I should install with cpu version because I am using Radeon Vega 8 graphics.
Hope it helps.
回答8:
I have tried different methods still it doesn't work then I apply this method it works for me.
STOP you antivirus protection software for half hour then install anaconda,it works fine. 100%
回答9:
If you use python 3.6.10 and tensorflow 2.1.0 Just follow this -
pip install tensorflow==2.0
It worked for me.
回答10:
I had first Upgraded the Anaconda prompt
I had then used conda create -n tfp python=3.7
conda activate tfp
Then import the tensorflow
回答11:
I faced the similar issue for tensorflow 2.0 First I uninstalled tensorflow using pip uninstall tensorflow (no need to uninstall tensorflow-estimator or tensorboard). Then I reinstall using conda install tensorflow.
回答12:
Never install the latest version of tensorflow it will raise an error DLL file load error
pip install tensorflow
never run command on your computer as it not supports the tensorflow cpu most of the latest version supports mostly gpu
so while installing install the lower version of the tensorflow from my opininon the stable release of tensorflow is tensorflow 1.5 make sure you uninstalled your tensorflow installed in your computer pip uninstall tensorflow
After above step shutdown your pc and restart.Then only install tensorflow 1.5 command to install tensorflow version 1.5
pip install tensorflow==1.5
回答13:
Install Microsoft Visual C++ 2019 Redistributable & reboot the PC, it will work with tensorflow 2.3.1 in python 3.7
来源:https://stackoverflow.com/questions/49113497/python-tensorflow-import-dll-load-failed