crazy
crazy

Reputation: 11

unable to import chatterbot in python

python app.py

Traceback (most recent call last):
  File "app.py", line 1, in <module>
    from chatbot import chatbot
  File "C:\Users\hp\Desktop\try_projects\chat_bot\chatbot.py", line 1, in <module>
    from chatterbot import ChatBot
ModuleNotFoundError: No module named 'chatterbot'

Code is

from chatterbot import ChatBot
from chatterbot.trainers import ListTrainer, ChatterBotCorpusTrainer
 

chatbot= ChatBot('Crazy')

what might be the solution to this problem? python version: 3.8.3

Upvotes: 0

Views: 3093

Answers (1)

Vishnu Joshi
Vishnu Joshi

Reputation: 333

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()

I Hope this helped! This was my first answer on StackOverflow !

Upvotes: 5

Related Questions