簡體   English   中英

使用pip安裝后導入tensorflow和tflearn時出錯

[英]Error with importing tensorflow and tflearn after installing with pip

我已經在我的 Windows 機器上使用 pip 安裝了 tensorflow 和 tflearn。 我正在使用 pyhton 3.6,因為它是教程所要求的,因為 tflearn 對 python 3.7 有一些錯誤。 我正在嘗試創建一個從 json fil 讀取數據的聊天機器人,在測試我的代碼時,我遇到了一個問題,下面給出了幾個例外

當我嘗試運行此代碼時

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 出現一些問題之后,一切都是全新安裝的。 我自己無法破譯追溯,因此我希望你們中的一些人可以幫助我。 先感謝您!

這是因為 tflearn 僅支持最高 1.2 的 TensorFlow 版本。 您可以降級您的 TensorFlow 版本以使用上述代碼。

降級:

pip uninstall protobuf
pip uninstall tensorflow

要安裝 TensorFlow 1.x:

pip install tensorflow==1.15

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM