【问题标题】:Error with importing tensorflow and tflearn after installing with pip使用 pip 安装后导入 tensorflow 和 tflearn 出错
【发布时间】:2020-01-17 16:43:02
【问题描述】:

我已经在我的 Windows 机器上使用 pip 安装了 tensorflow 和 tflearn。我正在使用教程要求的pyhton 3.6,因为tflearn在python 3.7中有一些错误。 我正在尝试创建一个从 json 文件读取数据的聊天机器人,在测试我的代码时,我遇到了一个问题,下面给出了几个异常

当我试图运行这段代码时

import nltk
from nltk.stem.lancaster import LancasterStemmer
stemer = LancasterStemmer()

import numpy
import tflearn
import tensorflow
import random
import json

with open("intents.json") as file:
    data = json.load(file)

print(data)

我收到以下错误

Traceback (most recent call last):
  File "c:\Users\win 10\Desktop\chatbot\index.py", line 6, in <module>
    import tflearn
  File "C:\Users\win 10\AppData\Local\Programs\Python\Python36\lib\site-packages\tflearn\__init__.py", line 4, in <module>
    from . import config
  File "C:\Users\win 10\AppData\Local\Programs\Python\Python36\lib\site-packages\tflearn\config.py", line 3, in <module>
    import tensorflow as tf
  File "C:\Users\win 10\AppData\Local\Programs\Python\Python36\lib\site-packages\tensorflow\__init__.py", line 24, in <module>
    from tensorflow.python import *
  File "C:\Users\win 10\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\win 10\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\win 10\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.

在安装 TensorFLow 出现一些问题之后,一切都是全新安装的。我自己无法破译这些回溯,因此我希望你们中的一些人能帮助我。提前谢谢!

【问题讨论】:

  • 我也在使用 tensorflow 1.4 版,因为 2.0 不适用于 tflearn

标签: python tensorflow deep-learning neural-network tflearn


【解决方案1】:

这是因为 tflearn 仅支持最高 1.2 的 TensorFlow 版本。您可以降级您的 TensorFlow 版本以使用上述代码。

降级:

pip uninstall protobuf
pip uninstall tensorflow

要安装 TensorFlow 1.x:

pip install tensorflow==1.15

【讨论】: