4
from chatterbot import ChatBot
from chatterbot.trainers import ListTrainer
import os

bot = ChatBot('Bot')
bot.set_trainer(ListTrainer)

for files in os.listdir('D:/Anaconda3/Lib/site-packages/chatterbot_corpus/data/english'):
    data = open('D:/Anaconda3/Lib/site-packages/chatterbot_corpus/data/english' + files, 'r').readlines()
    bot.train(data)
while True:
    message = input('You')
    if message.strip() != 'Bye':

        reply = bot.get_response(message)
        print('ChatBot :', reply)
    if message.strip() == 'Bye':
        print('ChatBot : Bye')
        break  

I'm getting an error:

Traceback (most recent call last): File "C:\Users\nakulmagotra\Desktop\chatbot_train.py", line 1, in from chatterbot import ChatBot ModuleNotFoundError: No module named 'chatterbot'

I'm a complete noob to Chatterbot . Thanks.

PrakashG
  • 1,642
  • 5
  • 20
  • 30
Nakul Sharma
  • 41
  • 1
  • 2
  • and i have run the command python -m chatterbot --version in cmd it displays 1.0.2 and im working in anaconda3 with jupyter text editor. I'm a complete noob to pyhton and programming with python – Nakul Sharma Feb 13 '19 at 05:07
  • 2
    Maybe you have not installed `chatterbot` in Anaconda. Open anaconda prompt and type `pip install chatterbot` – Sociopath Feb 13 '19 at 05:13
  • maybe start from how venv works in python – confiq Feb 13 '19 at 10:32

4 Answers4

3

According to this, you should install it by pip install chatterbot or setup manually with git clone https://github.com/gunthercox/ChatterBot and into the cloned directory run python setup.py install. After that, you can simply check it by using import chatterbot and see if it showing error or not.

Masoud Rahimi
  • 5,785
  • 15
  • 39
  • 67
1

This Error Maybe due to Some reason.

  • chatter is not installed try pip install chatterbot
  • You are using a different environment. try to change the environment
  • chatterbot is not in the path
Deepak Raj
  • 462
  • 5
  • 15
1

Try installing the previous version of ChatterBot.

pip install chatterbot==1.0.4

This should work, unless there are some other problems. I had the same problem and it worked for me.

There would be another problem if you are using Python 3.8.x . In Python 3.8.x, a few functions of a few modules were removed. You will be able to import ChattberBot , but when you name the bot, there will be an error.

 File "C:\Python38\lib\site-packages\sqlalchemy\util\compat.py", line 264, in <module>
time_func = time.clock
AttributeError: module 'time' has no attribute 'clock'

Copy the location for the file given in the last line, where the error occurs.

C:\Python38\lib\site-packages\sqlalchemy\util\compat.py

Open file with IDLE or whatever editor you have. Please do Not open the file directly(this will run the file, and you will not be able to see the code) , instead Open with IDLE or Your Text editor Then , go to line 264 in that . It would be written

time_func = time.clock

Instead of this change it to

time_func = time.perf_counter()
Vishnu Joshi
  • 333
  • 1
  • 9
0

Open terminal in pycharm Write pip install chatterbox Then one error may occur that time has no module clock To fix it Copy the location of last error Then open it on pycharm not open it directly Go in line no.264 And change it time clock() to time per_counter