无法导入TensorFlow和Keras
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了无法导入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:UserskolasayAppDataRoamingPythonPython36site-packages ensorflow\__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:UserskolasayAppDataRoamingPythonPython36site-packages ensorflowpython\__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:UserskolasayAppDataRoamingPythonPython36site-packages ensorflowcoreframeworkgraph_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:UserskolasayAppDataRoamingPythonPython36site-packagesgoogleprotobufdescriptor.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这样的在线环境进行玩具项目,因为设置起来不那么麻烦。
以上是关于无法导入TensorFlow和Keras的主要内容,如果未能解决你的问题,请参考以下文章
AttributeError:模块“tensorflow”在 conda 提示中没有属性“keras”
无法在 PyCharm 2019.2 中导入 Keras(来自 TensorFlow 2.0)