【问题标题】:python tensorflow import dll load failedpython tensorflow导入dll加载失败
【发布时间】:2018-08-13 06:54:03
【问题描述】:

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

然后使用 pip3 为 cpu-only 安装 tensorflow

C:\>pip3 install tensorflow

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

它显示了下面的错误

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

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

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

那么这里到底是什么问题

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

我的操作系统:带有 Service Pack 1 / 64 位 / 英特尔酷睿 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.

【问题讨论】:

标签: python tensorflow dll


【解决方案1】:

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

【讨论】:

    【解决方案2】:

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

    pip install tensorflow
    

    永远不要在你的电脑上运行命令,因为它不支持 tensorflow cpu 大多数最新版本大多支持gpu

    所以在安装时安装较低版本的 tensorflow 从我的观点来看,tensorflow 的稳定版本是 tensorflow 1.5 确保您卸载了计算机中安装的 tensorflow pip卸载张量流

    完成上述步骤后,关闭您的电脑并重新启动。然后只安装 tensorflow 1.5 安装tensorflow 1.5版的命令

    pip install tensorflow==1.5
    

    【讨论】:

      【解决方案3】:

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

      【讨论】:

        【解决方案4】:

        我有同样的问题。 我升级了 pip 版本:

        python -m pip install --upgrade pip
        

        还有,降级了

        pip install tensorflow==2.0
        

        成功了

        【讨论】:

          【解决方案5】:

          我首先升级了 Anaconda 提示符

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

          conda 激活 tfp

          然后导入张量流

          【讨论】:

            【解决方案6】:

            如果你使用 python 3.6.10 和 tensorflow 2.1.0 跟着这个 -

            pip install tensorflow==2.0

            它对我有用。

            【讨论】:

              【解决方案7】:

              我尝试了不同的方法仍然不起作用然后我应用它对我有用的方法。

              停止你的杀毒保护软件半小时,然后安装 anaconda,它工作正常。 100%

              【讨论】:

                【解决方案8】:

                我修好了。 花几天时间搜索修复它们。

                使用 pip install tensorflow-cpu 安装 tensorflow
                更新了 Visual C++ 2015-2019

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

                希望对你有帮助。

                【讨论】:

                  【解决方案9】:

                  ImportError: DLL 加载失败
                  对于
                  窗户 10
                  蟒蛇 3.6

                   pip install protobuf==3.6.0    
                  

                  pip3 install protobuf==3.6.0
                  

                  【讨论】:

                    【解决方案10】:

                    您的 CPU 可能没有 AVX 指令(自 1.6 以来所有 tensorflow 二进制文件都需要该指令)。您可以使用诸如 CPU-Z 之类的工具进行检查。如果是这种情况,您可以在此处下载正确的车轮(使用 SSE2 二进制文件):

                    tensorflow-windows-wheel

                    【讨论】:

                      【解决方案11】:

                      我将 tensorflow 降级到 1.10.0 并解决了问题

                      【讨论】:

                        【解决方案12】:

                        我在使用 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 希望对您有所帮助!

                        【讨论】:

                        • 谢谢,这对我有用。我的 Anaconda 安装版本是 5.2.0。通过 Anaconda Navigator 安装 tensorflow 1.12.0 不起作用,但按照自己的方式安装就可以了。我必须为您的第 5 行 cd 到 C:\Users\Username\Anaconda3\Scripts。
                        【解决方案13】:

                        我在 win7 64 位(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 对您有所帮助。

                        【讨论】:

                        猜你喜欢
                        • 2021-04-28
                        • 2020-11-19
                        • 1970-01-01
                        • 1970-01-01
                        • 2011-05-03
                        • 2019-09-08
                        • 2016-01-09
                        • 2020-09-21
                        • 2019-01-16
                        相关资源
                        最近更新 更多