pythontensorflowdeep-learningneural-networktflearn

Error with importing tensorflow and tflearn after installing with pip


I have installed tensorflow and tflearn using pip on my windows machine. I am using pyhton 3.6 as it was asked by the tutorial because tflearn has some bug with python 3.7. I am trying to create a chatbot which reads data from a json fil and while testing my code, I ran into an issue with several exceptions given bellow

when i am trying to run this code

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)

I am getting the following error

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.

Everything is freshly installed, after some issues with installing TensorFLow. I can't decipher the tracebacks myself, therefore I am hoping some of you guys can help me. Thank you in advance!


Solution

  • It's because tflearn has support for TensorFlow version up to 1.2 only. You can downgrade your TensorFlow version to use the above code.

    To downgrade:

    pip uninstall protobuf
    pip uninstall tensorflow
    

    To install TensorFlow 1.x:

    pip install tensorflow==1.15