ImportError when trying to use tflearn

I am learning to code AI Chatbots in Python, and I tried to run this code from here:

import nltk
from import LancasterStemmer
stemmer = LancasterStemmer()

import numpy
import tflearn
import tensorflow
import random
import json
import pickle

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

    with open("data.pickle", "rb") as f:
        words, labels, training, output = pickle.load(f)
    words = []
    labels = []
    docs_x = []
    docs_y = []

    for intent in data["intents"]:
        for pattern in intent["patterns"]:
            wrds = nltk.word_tokenize(pattern)

        if intent["tag"] not in labels:

    words = [stemmer.stem(w.lower()) for w in words if w != "?"]
    words = sorted(list(set(words)))

    labels = sorted(labels)

    training = []
    output = []

    out_empty = [0 for _ in range(len(labels))]

    for x, doc in enumerate(docs_x):
        bag = []

        wrds = [stemmer.stem(w.lower()) for w in doc]

        for w in words:
            if w in wrds:

        output_row = out_empty[:]
        output_row[labels.index(docs_y[x])] = 1


    training = numpy.array(training)
    output = numpy.array(output)

    with open("data.pickle", "wb") as f:
        pickle.dump((words, labels, training, output), f)


net = tflearn.input_data(shape=[None, len(training[0])])
net = tflearn.fully_connected(net, 8)
net = tflearn.fully_connected(net, 8)
net = tflearn.fully_connected(net, len(output[0]), activation="softmax")
net = tflearn.regression(net)

model = tflearn.DNN(net)

except:, output, n_epoch=1000, batch_size=8, show_metric=True)"model.tflearn")

def bag_of_words(s, words):
    bag = [0 for _ in range(len(words))]

    s_words = nltk.word_tokenize(s)
    s_words = [stemmer.stem(word.lower()) for word in s_words]

    for se in s_words:
        for i, w in enumerate(words):
            if w == se:
                bag[i] = 1
    return numpy.array(bag)

def chat():
    print("Start talking with the bot (type quit to stop)!")
    while True:
        inp = input("You: ")
        if inp.lower() == "quit":

        results = model.predict([bag_of_words(inp, words)])
        results_index = numpy.argmax(results)
        tag = labels[results_index]

        for tg in data["intents"]:
            if tg['tag'] == tag:
                responses = tg['responses']



when I get this error:

WARNING:tensorflow:From C:\Users\user\AppData\Local\Programs\Python\Python310\lib\site-packages\tflearn\ The name tf.disable_v2_behavior is deprecated. Please use tf.compat.v1.disable_v2_behavior instead.

WARNING:tensorflow:From C:\Users\user\AppData\Local\Programs\Python\Python310\lib\site-packages\tensorflow\python\compat\ disable_resource_variables (from tensorflow.python.ops.variable_scope) is deprecated and will be removed in a future version.
Instructions for updating:
non-resource variables are not supported in the long term
curses is not supported on this machine (please install/reinstall curses for an optimal experience)
WARNING:tensorflow:From C:\Users\user\AppData\Local\Programs\Python\Python310\lib\site-packages\tflearn\helpers\ The name tf.summary.merge is deprecated. Please use tf.compat.v1.summary.merge instead.

Traceback (most recent call last):
  File "C:\Users\user\Documents\", line 6, in <module>
    import tflearn
  File "C:\Users\user\AppData\Local\Programs\Python\Python310\lib\site-packages\tflearn\", line 25, in <module>
    from .layers import normalization
  File "C:\Users\user\AppData\Local\Programs\Python\Python310\lib\site-packages\tflearn\layers\", line 11, in <module>
    from .recurrent import lstm, gru, simple_rnn, bidirectional_rnn, \
  File "C:\Users\user\AppData\Local\Programs\Python\Python310\lib\site-packages\tflearn\layers\", line 17, in <module>
    from tensorflow.python.util.nest import is_sequence
ImportError: cannot import name 'is_sequence' from 'tensorflow.python.util.nest' (C:\Users\user\AppData\Local\Programs\Python\Python310\lib\site-packages\tensorflow\python\util\

And it’s coming from this line:

import tflearn

Any fixes? I use Python 3.10.6.

Far as I can see from a little basic googling, tflearn was abandoned 4 years ago. You can try to install the very latest version by doing

pip uninstall tflearn
pip install git+

But I cant guarantee that’ll fix it, or if it does, for how long. It looks like you’ve got other installation issues there too.

Agh, I should have thought about that, is there any up to date libraries apart from this github package? Now that you mentioned it, many of the tutorials that I Googled uses abandoned libraries…