python - 无法导入 TensorFlow 和 Keras
问题描述
我无法导入 TensorFlow 和 Keras。我已经成功安装了它们并且能够看到版本,但是在导入时出现以下错误。
ImportError: DLL load failed: The specified procedure could not be found.
Product Versions
Python Version - 3.6
---
Anaconda Version - 4.3.1
--
Keras Version - 2.2.4
--------------------
TensorFlow Version - 1.31.1
-------------------------------
ImportError: DLL load failed: The specified procedure could not be found.
ImportError Traceback (most recent call last)
<ipython-input-1-41389fad42b5> in <module>()
1 import tensorflow as tf
C:\Users\kolasay\AppData\Roaming\Python\Python36\site-packages\tensorflow\__init__.py in <module>()
22
23 # pylint: disable=g-bad-import-order
24 from tensorflow.python import pywrap_tensorflow # pylint: disable=unused-import
25
26 from tensorflow._api.v1 import app
C:\Users\kolasay\AppData\Roaming\Python\Python36\site-packages\tensorflow\python\__init__.py in <module>()
50
51 # Protocol buffers
52 from tensorflow.core.framework.graph_pb2 import *
53 from tensorflow.core.framework.node_def_pb2 import *
54 from tensorflow.core.framework.summary_pb2 import *
C:\Users\kolasay\AppData\Roaming\Python\Python36\site-packages\tensorflow\core\framework\graph_pb2.py in <module>()
4 import sys
5 _b=sys.version_info[0]<3 and (lambda x:x) or (lambda x:x.encode('latin1'))
6 from google.protobuf import descriptor as _descriptor
7 from google.protobuf import message as _message
8 from google.protobuf import reflection as _reflection
C:\Users\kolasay\AppData\Roaming\Python\Python36\site-packages\google\protobuf\descriptor.py in <module>()
45 import binascii
46 import os
47 from google.protobuf.pyext import _message
48 _USE_C_DESCRIPTORS = getattr(_message, '_USE_C_DESCRIPTORS', False)
49
ImportError: DLL load failed: The specified procedure could not be found.
解决方案
通过这个线程,我可以建议以下内容
https://github.com/protocolbuffers/protobuf/issues/5046
- 将 Protobuf 降级到稳定版本
- 将 Python 升级到 3.6.1
将来我可能会建议为玩具项目选择像 Google Colab 这样的在线环境,因为它设置起来不那么麻烦。
推荐阅读
- python - 如何矢量化涉及 python 中 type() 函数的 for 循环操作
- c# - EF.Core 迁移 - 具有继承类 ID 的抽象类关系
- swagger - nestjs 招摇默认 apiproperty 到当前日期
- java - 我可以使用 JPA 存储库查询将元素添加/插入到我的 ElementCollection 中吗?
- server - 为什么Installshield在2019 Datacenter上卸载时不删除服务,即在域上
- lastpass - 如何在 LastPass 中查找所有包含文件/附件的记录?
- java - 为什么在 Java 中使用实例变量时要声明(最终)局部变量?
- vb.net - vb.net - TCP 发送器/侦听器不能在单台机器之外工作
- json - 将标准 JSON 插入 DynamoDB aws-sdk js v3
- python - 将Json数据加载到python中的数据框中