windows - 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 中究竟缺少什么?
解决方案
安装时有什么问题吗?另外,当 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 看看是否可行。祝你好运!
推荐阅读
- python - Python/Docker:如何在 docker 中使用 python 日志记录模块?
- ruby-on-rails - 如何通过 minitest 测试 after_sign_in_path_for
- c# - vs 2017 asp.net core 2.2中缺少上下文菜单以添加控制器
- javascript - 使用 javascript 在两个新选项卡中打开两个 url,而不使用弹出窗口阻止程序
- javascript - 打印多个评论的明星
- ruby-on-rails - Rails 服务器的 LoadError 问题
- spring-mvc - 在freeswitch中获取带有url的参数
- c# - 在 MVC5 中使用表单身份验证时,按钮单击以不同的操作方法触发
- netlogo - Netlogo - 行为空间
- rust - 如何为具有生命周期'a的结构实现具有'静态生命周期的特征?