installed chatbot but getting error while importing chatbot

  • Last Update :
  • Techknowledgy :

Try installing the previous version of ChatterBot.

pip install chatterbot == 1.0 .4

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

Instead of this change it to

time_func = time.perf_counter()

Suggestion : 2

According to this, you should install it anycodings_python by pip install chatterbot or setup anycodings_python manually with git clone anycodings_python https://github.com/gunthercox/ChatterBot anycodings_python and into the cloned directory run python anycodings_python setup.py install. After that, you can anycodings_python simply check it by using import anycodings_python chatterbot and see if it showing error anycodings_python or not.,This should work, unless there are some anycodings_python other problems. I had the same problem anycodings_python and it worked for me.,Try installing the previous version of anycodings_python ChatterBot.,Open terminal in pycharm Write pip anycodings_python install chatterbox Then one error may anycodings_python occur that time has no module clock To anycodings_python fix it Copy the location of last anycodings_python error Then open it on pycharm not open anycodings_python it directly Go in line no.264 And change anycodings_python it time clock() to time per_counter

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

Try installing the previous version of anycodings_python ChatterBot.

pip install chatterbot == 1.0 .4

There would be another problem if you anycodings_python are using Python 3.8.x . In Python anycodings_python 3.8.x, a few functions of a few modules anycodings_python were removed. You will be able to import anycodings_python ChattberBot , but when you name the bot, anycodings_python 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 anycodings_python the last line, where the error occurs.

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

Instead of this change it to

time_func = time.perf_counter()

Suggestion : 3

Create a new file named chatbot.py. Then open chatbot.py in your editor of choice.,Before we do anything else, ChatterBot needs to be imported. The import for ChatterBot should look like the following line.,This line of code has created a new chat bot named Norman. There is a few more parameters that we will want to specify before we run our program for the first time.,Next, you will want to create a while loop for your chat bot to run in. By breaking out of the loop when specific exceptions are triggered, we can exit the loop and stop the program when a user enters ctrl+c.

pip install chatterbot
from chatterbot
import ChatBot
bot = ChatBot('Norman')
bot = ChatBot(
   'Norman',
   storage_adapter = 'chatterbot.storage.SQLStorageAdapter',
   database_uri = 'sqlite:///database.sqlite3'
)
bot = ChatBot(
   'Norman',
   storage_adapter = 'chatterbot.storage.SQLStorageAdapter',
   logic_adapters = [
      'chatterbot.logic.MathematicalEvaluation',
      'chatterbot.logic.TimeLogicAdapter'
   ],
   database_uri = 'sqlite:///database.sqlite3'
)
while True:
   try:
   bot_input = bot.get_response(input())
print(bot_input)

except(KeyboardInterrupt, EOFError, SystemExit):
   break

Suggestion : 4

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',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,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., 2 Maybe you have not installed chatterbot in Anaconda. Open anaconda prompt and type pip install chatterbot – Sociopath Feb 13, 2019 at 5:13

Try installing the previous version of ChatterBot.

pip install chatterbot == 1.0 .4

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

Instead of this change it to

time_func = time.perf_counter()

Suggestion : 5

no module name ‘en’ error is coming ``from chatterbot import ChatBot bot=ChatBot( ‘Friday’, storage_adapter=‘chatterbot.storage.SQLStorageAdapter’, #collect database logic_adapters=[ ‘chatterbot.logic.MathematicalEvaluation’, ‘chatterbot.logic.TimeLogicAdapter’ ‘chatterbot.logic.BestMatch’], database_uri=‘sqlite:///database.db’) print(‘Ask something!!’) while True: try: user_input = input() bot_response = bot.get_response(user_input) print(bot_response) except (KeyboardInterrupt, EOFError, SystemExit): break,That’s happening because spacy isn’t loading correctly. you need to link whatever spacy model you have installed to the name en.,or like the error says their is no module name spacy you may not have spacy installed have you installed it using pip install spacy?,Open up CMD as administrator and create your link (something similar to below) mklink /d E:\MyProjects\ChatBot\venv\Lib\site-packages\spacy\data\en E:\MyProjects\ChatBot\venv\Lib\site-packages\en_core_web_sm

For example, if you have en_core_web_sm installed:

python - m spacy link en_core_web_sm en