1

im new to this. trying to make a chatbot and following this playlist: https://www.youtube.com/watch?v=PzzHOvpqDYs&t=14s currently at part 3

Reached the end of the video ran the code:

chatbot.py

import nltk
from nltk.stem.lancaster import LancasterStemmer
import numpy
import tensorflow
import random
import json
import tflearn


stemmer = LancasterStemmer

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

words = []
labels = []
docs_x = []
docs_y = []

for intent in data["intents"]:
    for pattern in intent["patterns"]:
        wrds = nltk.word_tokenize(pattern)
        words.extend(wrds)
        docs_x.append(wrds)
        docs_y.append(intent["tag"])

        if intent["tag"] not in labels:
            labels.append(intent["tags"])

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) for w in doc]

    for w in words:
        if w in wrds:
            bag.append(1)
        else:
            bag.append(0)

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

    training.append(bag)
    output.append(output_row)

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


tensorflow.reset_default_graph()

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)

model.fit(training, output, n_epoch=1000, batch_size=8, show_metric=True)
model.save("model.tflearn")

and this error occurred:

Traceback (most recent call last):
  File "C:\Users\NJ\AppData\Local\Programs\Python\Python38-32\lib\site-packages\tensorflow\python\pywrap_tensorflow_internal.py", line 18, in swig_import_helper
    fp, pathname, description = imp.find_module('_pywrap_tensorflow_internal', [dirname(__file__)])
  File "C:\Users\NJ\AppData\Local\Programs\Python\Python38-32\lib\imp.py", line 296, in find_module
    raise ImportError(_ERR_MSG.format(name), name=name)
ImportError: No module named '_pywrap_tensorflow_internal'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "C:\Users\NJ\AppData\Local\Programs\Python\Python38-32\lib\site-packages\tensorflow\python\pywrap_tensorflow.py", line 58, in <module>
    from tensorflow.python.pywrap_tensorflow_internal import *
  File "C:\Users\NJ\AppData\Local\Programs\Python\Python38-32\lib\site-packages\tensorflow\python\pywrap_tensorflow_internal.py", line 28, in <module>
    _pywrap_tensorflow_internal = swig_import_helper()
  File "C:\Users\NJ\AppData\Local\Programs\Python\Python38-32\lib\site-packages\tensorflow\python\pywrap_tensorflow_internal.py", line 20, in swig_import_helper
    import _pywrap_tensorflow_internal
ModuleNotFoundError: No module named '_pywrap_tensorflow_internal'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "C:/Users/NJ/PycharmProjects/pylab/chatbot.py", line 4, in <module>
    import tensorflow
  File "C:\Users\NJ\AppData\Local\Programs\Python\Python38-32\lib\site-packages\tensorflow\__init__.py", line 24, in <module>
    from tensorflow.python import pywrap_tensorflow  # pylint: disable=unused-import
  File "C:\Users\NJ\AppData\Local\Programs\Python\Python38-32\lib\site-packages\tensorflow\python\__init__.py", line 49, in <module>
    from tensorflow.python import pywrap_tensorflow
  File "C:\Users\NJ\AppData\Local\Programs\Python\Python38-32\lib\site-packages\tensorflow\python\pywrap_tensorflow.py", line 74, in <module>
    raise ImportError(msg)
ImportError: Traceback (most recent call last):
  File "C:\Users\NJ\AppData\Local\Programs\Python\Python38-32\lib\site-packages\tensorflow\python\pywrap_tensorflow_internal.py", line 18, in swig_import_helper
    fp, pathname, description = imp.find_module('_pywrap_tensorflow_internal', [dirname(__file__)])
  File "C:\Users\NJ\AppData\Local\Programs\Python\Python38-32\lib\imp.py", line 296, in find_module
    raise ImportError(_ERR_MSG.format(name), name=name)
ImportError: No module named '_pywrap_tensorflow_internal'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "C:\Users\NJ\AppData\Local\Programs\Python\Python38-32\lib\site-packages\tensorflow\python\pywrap_tensorflow.py", line 58, in <module>
    from tensorflow.python.pywrap_tensorflow_internal import *
  File "C:\Users\NJ\AppData\Local\Programs\Python\Python38-32\lib\site-packages\tensorflow\python\pywrap_tensorflow_internal.py", line 28, in <module>
    _pywrap_tensorflow_internal = swig_import_helper()
  File "C:\Users\NJ\AppData\Local\Programs\Python\Python38-32\lib\site-packages\tensorflow\python\pywrap_tensorflow_internal.py", line 20, in swig_import_helper
    import _pywrap_tensorflow_internal
ModuleNotFoundError: No module named '_pywrap_tensorflow_internal'


Failed to load the native TensorFlow runtime.

See https://www.tensorflow.org/install/errors

for some common reasons and solutions.  Include the entire stack trace
above this error message when asking for help.

Process finished with exit code 1

I dont understand what im doing wrong, my IDE shows no error and im using pycharm btw Pls help, thank you

edit:

switched my interpreter to the other python which was I believe to be the 64-bit

and the error changed to this:

2020-06-24 12:39:14.345521: W tensorflow/stream_executor/platform/default/dso_loader.cc:55] Could not load dynamic library 'cudart64_101.dll'; dlerror: cudart64_101.dll not found
2020-06-24 12:39:14.345896: I tensorflow/stream_executor/cuda/cudart_stub.cc:29] Ignore above cudart dlerror if you do not have a GPU set up on your machine.
Traceback (most recent call last):
  File "C:/Users/NJ/PycharmProjects/pylab/chatbot.py", line 7, in <module>
    import tflearn
  File "C:\Users\NJ\PycharmProjects\pylab\venv\lib\site-packages\tflearn\__init__.py", line 4, in <module>
    from . import config
  File "C:\Users\NJ\PycharmProjects\pylab\venv\lib\site-packages\tflearn\config.py", line 5, in <module>
    from .variables import variable
  File "C:\Users\NJ\PycharmProjects\pylab\venv\lib\site-packages\tflearn\variables.py", line 7, in <module>
    from tensorflow.contrib.framework.python.ops import add_arg_scope as contrib_add_arg_scope
ModuleNotFoundError: No module named 'tensorflow.contrib'

Process finished with exit code 1
Njay
  • 23
  • 4
  • This is usually caused by the incompatibility of your hardware, driver and tensorflow version. You may refer to https://stackoverflow.com/questions/44080677/no-module-named-pywrap-tensorflow-internal for more details. – whilrun Jun 24 '20 at 04:18
  • Does this answer your question? [No Module Named '\_pywrap\_tensorflow\_internal'](https://stackoverflow.com/questions/44080677/no-module-named-pywrap-tensorflow-internal) – whilrun Jun 24 '20 at 04:18
  • is that still relevant? its 3 years ago? – Njay Jun 24 '20 at 04:27
  • and how do I know what version of tensorflow should I use? – Njay Jun 24 '20 at 04:29
  • How do you install tensorflow? Normally anaconda's version fits best. – whilrun Jun 24 '20 at 04:30
  • The error is raised basically because your tensorflow installation lacks some key components (DLLs etc.), so you may just reinstall the whole tensorflow and if you have a GPU installed, make sure the driver version matches. – whilrun Jun 24 '20 at 04:33
  • I changed the interpreter and edited my question and show this new error – Njay Jun 24 '20 at 04:45
  • TensorFlow 2.0 has removed contrib module, so you need to stick to tensorflow 1.14 version. The tensorflow version problem is quite annoying, so you may need to try different versions to make it work. – whilrun Jun 24 '20 at 05:34
  • ran `pip install tensorflow==1.14` received this error: `ERROR: Could not find a version that satisfies the requirement tensorflow==1.14 (from versions: 2.2.0rc1, 2.2.0rc2, 2.2.0rc3, 2.2.0rc4, 2.2.0) ERROR: No matching distribution found for tensorflow==1.14 ` – Njay Jun 24 '20 at 05:52
  • machine learning is really complicated. I get a lot of errors just by installing all kinds of packages just like the chatterbot. – Njay Jun 24 '20 at 05:57
  • Are you using Python 3.8? If so, you need to downgrade to 3.7 since tensorflow version 1 is not available for Python 3.8. – whilrun Jun 24 '20 at 06:30
  • I would personally prefer pytorch since it is easier to read and use. But that is a whole different topic. If you are interested in it, you may google it for more information. – whilrun Jun 24 '20 at 06:36
  • pytorch? got me interested.. is that some library/package for ML? – Njay Jun 24 '20 at 06:43
  • 1
    It is an ML framework just like TensorFlow, but has more convenient features and is the most popular framework for research. – whilrun Jun 24 '20 at 06:51
  • Make sure you use Python 3.7 or lower or Tensorflow 1 version and upgrade pip to latest version. For Tesorflow 2 you can use your current python version, but contrib is depreciated in Tensorflow 2, you need to replace with alternatives from this link or rewrite the code https://github.com/tensorflow/community/blob/master/rfcs/20180907-contrib-sunset.md –  Nov 29 '20 at 08:26

0 Answers0