首页 > 解决方案 > Python 3.6 - 导入 tensorflow 时,Tensorflow DLL 加载失败

问题描述

我在 Python 3.6 上使用 pip3 在命令提示符下安装了 Tensorflow:

pip3 install tensorflow==1.5

在检查是否可以使用 Python 从终端导入 tensorflow 时,我收到以下错误消息:

Python 3.6.0rc2 (v3.6.0rc2:800a67f7806d, Dec 16 2016, 23:22:07) [MSC v.1900 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import tensorflow as tf

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "C:\Users\{User}\AppData\Local\Programs\Python\Python36\lib\site-packages\tensorflow\__init__.py", line 24, in <module>
    from tensorflow.python import *
  File "C:\Users\{User}\AppData\Local\Programs\Python\Python36\lib\site-packages\tensorflow\python\__init__.py", line 52, in <module>
    from tensorflow.core.framework.graph_pb2 import *
  File "C:\Users\{User}\AppData\Local\Programs\Python\Python36\lib\site-packages\tensorflow\core\framework\graph_pb2.py", line 6, in <module>
    from google.protobuf import descriptor as _descriptor
  File "C:\Users\{User}\AppData\Local\Programs\Python\Python36\lib\site-packages\google\protobuf\descriptor.py", line 47, in <module>
    from google.protobuf.pyext import _message
ImportError: DLL load failed: The specified procedure could not be found.

DLL 中究竟缺少什么?

标签: windowstensorflowpython-3.6

解决方案


安装时有什么问题吗?另外,当 1.9 可用时,为什么要安装 tensorflow 1.5?我会先尝试pip uninstall tensorflow然后pip install tensorflow。如果您仍然有问题,我会尝试去这里下载 .whl 文件,然后您可以这样做pip install [whatever the filename is].whl。直接安装这些 .whl 文件为我解决了很多问题。

要回答您的问题,您似乎缺少 google protobuf 中的 descriptor.py。您可以尝试下载该文件并直接移动descriptor.py,但我的猜测是,如果它找不到一个文件,它也可能会丢失其他东西。

查看 tensorflow 导入的其他问题,看起来问题是与 python 3.6 的兼容性,与 pip 有不同的路径,但看起来这个问题在去年的某个时候得到了解决。如果你还是卡住了,当然可以尝试升级 pip、python 和 tensorflow;然后尝试降级到 python 3.5 看看是否可行。祝你好运!


推荐阅读