python tensorflow导入DLL加载失败

时间:2018-03-05 15:10:15

标签: python tensorflow dll

我安装了最新的python 3.6.4 x64版本

然后用pip3

安装了仅用于cpu的tensorflow
C:\>pip3 install tensorflow

但是当我尝试在python中导入tensorflow时

它向我显示了以下错误

我确信我已经安装了Microsoft Visual C ++ 2015 Redistributable(x64)

所以它不会是dll msvcp140.dll丢失的问题

它说“DLL加载失败,错误代码为-1073741795”

所以这里究竟出现了什么问题

我找不到有关此错误代码的任何其他信息

我的操作系统:带有Service Pack 1/64位/ intel核心i5 M 540的Windows 7企业

>>> 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.

13 个答案:

答案 0 :(得分:4)

我在win7 64bit(Intel Core 2 Duo Cpu T6670 2.2GHz)上使用tensorflow1.6-CPU也遇到了同样的问题

在我发现这个之后,它解决了我的问题。

参考此问题:https://github.com/tensorflow/tensorflow/issues/17386

通过此tensorflow-1.6.0-cp36-cp36m-win_amd64.whl重新安装:https://github.com/fo40225/tensorflow-windows-wheel/tree/master/1.6.0/py36/CPU/sse2

希望这个.whl可以帮到你。

答案 1 :(得分:1)

我在tensorflow-1.12.0中遇到了同样的问题 我所做的是:

  1. 安装anaconda
  2. 打开anaconda提示
  3. conda create -n tfp python=3.6
  4. activate tfp
  5. conda install tensorflow
  6. python
  7. 现在通过导入tensorflow进行检查

我使用的版本是3.6,但是您也可以尝试使用3.7 希望对您有帮助!

答案 2 :(得分:1)

我将tensorflow降级为1.10.0,并解决了该问题

答案 3 :(得分:1)

我有同样的问题。 我使用以下方式升级了pip版本:

python -m pip install --upgrade pip

也,降级为

pip install tensorflow==2.0

成功了

答案 4 :(得分:0)

您的CPU可能没有针对AVX的指令(自1.6开始,所有Tensorflow二进制文件都需要该指令)。您可以使用某些工具(例如CPU-Z)进行检查。在这种情况下,您可以在此处下载正确的车轮(使用SSE2二进制文件):

enter link description here

答案 5 :(得分:0)

ImportError:DLL加载失败
用于
Windows 10
python 3.6

 pip install protobuf==3.6.0    

pip3 install protobuf==3.6.0

答案 6 :(得分:0)

我修复了它。 花几天时间进行搜索以解决这些问题。

使用"psr-4": { "dealspace_websocket\\": "websocket_src/" } 安装了tensorflow
更新了Visual C ++ 2015-2019

问题是因为我没有nvidia图形,所以我应该安装cpu版本,因为我使用的是Radeon Vega 8图形。

希望有帮助。

答案 7 :(得分:0)

我尝试了其他方法,但仍然无法正常工作,然后我采用了适用于我的方法。

将防病毒保护软件停止运行半小时,然后安装anaconda,它可以正常工作。 100%

答案 8 :(得分:0)

如果您使用python 3.6.10和tensorflow 2.1.0 只需遵循此-

pip install tensorflow == 2.0

对我有用。

答案 9 :(得分:0)

我首先升级了Anaconda提示

然后我使用了conda create -n tfp python = 3.7

conda激活tfp

然后导入tensorflow

答案 10 :(得分:0)

我在tensorflow 2.0中遇到了类似的问题 首先,我使用 pip卸载tensorflow 卸载了tensorflow(无需卸载tensorflow-estimator或tensorboard)。 然后我使用 conda install tensorflow 重新安装。

答案 11 :(得分:0)

永远不要安装最新版本的tensorflow会引发错误 DLL文件加载错误

pip install tensorflow

永远不要在您的计算机上运行命令,因为它不支持tensorflow cpu 大多数最新版本主要支持GPU

因此在安装时安装较低版本的tensorflow 从我的观点来看,tensorflow的稳定释放是tensorflow 1.5 确保您卸载了安装在计算机中的tensorflow pip卸载tensorflow

完成上述步骤后,关闭计算机并重新启动。然后仅安装tensorflow 1.5 安装tensorflow 1.5版的命令

pip install tensorflow==1.5

答案 12 :(得分:0)

安装Microsoft Visual C ++ 2019 Redistributable并重新启动PC,它将与python 3.7中的tensorflow 2.3.1一起使用