File "/usr/local/lib/python3.6/dist-packages/chatterbot/trainers.py", line 48, in get_or_create
statement = self.storage.find(temp_statement.text)
AttributeError: 'ChatBot' object has no attribute 'find'
why?
Hi @azzhu The find attribute has been removed from ChatterBot in the latest development version. I'm not sure why you're seeing this error but if you re-download and install ChatterBot I'm confident that the issue will be resolved. If doing this does not fix the issue, I'd be happy to help you debug it further.
thanks !!!
@gunthercox Sorry, I still can't solve this problem. this is my code:
# -*- coding: utf-8 -*-
from chatterbot import ChatBot
from chatterbot.trainers import ListTrainer
chatbot = ChatBot('Charlie')
trainer = ListTrainer(chatbot)
trainer.train([
"Hi, can I help you?",
"Sure, I'd like to book a flight to Iceland.",
"Your flight has been booked."
])
# Get a response to the input text 'I would like to book a flight.'
response = chatbot.get_response('I would like to book a flight.')
print(response)
this is the error msg:
/usr/bin/python3.6 /home/lsg/PycharmProjects/test_tensorflow_gpu/test_chatterbot.py
List Trainer: [####### ] 33%Traceback (most recent call last):
File "/home/lsg/PycharmProjects/test_tensorflow_gpu/test_chatterbot.py", line 12, in
"Your flight has been booked."
File "/usr/local/lib/python3.6/dist-packages/chatterbot/trainers.py", line 110, in train
statement = self.get_or_create(text)
File "/usr/local/lib/python3.6/dist-packages/chatterbot/trainers.py", line 48, in get_or_create
statement = self.storage.find(temp_statement.text)
AttributeError: 'ChatBot' object has no attribute 'find'
Can you help me? thank you very much!
Hi, @azzhu, I've reviewed the code you posted and it looks correct. I believe the issue is with the chatterbot package that is installed on your system. Can you try uninstalling it and then reinstalling it to make sure the correct version is downloaded?
sudo pip3 uninstall chatterbot
sudo pip3 install chatterbot --no-cache-dir
@gunthercox thanks!!! it's ok.
@gunthercox I am new to this. I have also tried the steps that you have mentioned above i.e uninstalled and re-installed again. But the error is still the same.
AttributeError: 'ChatBot' object has no attribute 'find'
Can you please help?
@Jereemi Could you verify the version of ChatterBot you have installed? python3 -m chatterbot --version
@Jereemi Could you verify the version of ChatterBot you have installed?
python3 -m chatterbot --version
@gunthercox Yes..I have checked the version too..its Chatterbot 0.8.7
Interesting, and you used pip to install it?
Interesting, and you used
pipto install it?
@gunthercox I have tried running it with both pip and pip3 just to make it sure. The other codes are running fine both on python2 and python3 environment but this particular code-named learning_new_response.py could not be executed. I am getting the above-mentioned error.
The find attribute _was_ recently removed in the 1.0.0a1 release, but I'm uncertain why you'd be getting this message from version 0.8.7.
Have you tried downgrading to the previous version?
pip3 install chatterbot==0.8.6
The
findattribute _was_ recently removed in the1.0.0a1release, but I'm uncertain why you'd be getting this message from version0.8.7.Have you tried downgrading to the previous version?
pip3 install chatterbot==0.8.6
@gunthercox Yes, I have downgraded just now to Chatterbot 0.8.6 and I am still getting the same error:( Please check the steps that I followed while running this file.
The steps I followed: 1. Copied the contents of the file and paste it on my file and saved it as bot.py
Those steps are completely correct. I can't explain why you're seeing this error with the version you're using.
Those steps are completely correct. I can't explain why you're seeing this error with the version you're using.
@gunthercox Ok. Thank you anyways. Let me try to find a solution to this problem. I shall update if I can come up with a solution.
@gunthercox I have solved the problem by replacing the following 2 lines:
trainer = ChatterBotCorpusTrainer(bot)
trainer.train("chatterbot.corpus.english")
with the below lines:
bot.set_trainer(ChatterBotCorpusTrainer)
bot.train("chatterbot.corpus.english")
It worked fine. Hope this solution can be of some help to others too:)
I have the same issue and the code above don't solve my issue
@some81, can you post a sample of the code you ran that produced the error? The find method was removed from ChatterBot, I'm wondering if maybe you found an outdated example?
Hi @gunthercox,
I ran into the exact same problem.
I was using the example code from the README:
```from chatterbot import ChatBot
from chatterbot.trainers import ChatterBotCorpusTrainer
chatbot = ChatBot('Ron Obvious')
trainer = ChatterBotCorpusTrainer(chatbot)
trainer.train("chatterbot.corpus.english")
chatbot.get_response("Hello, how are you today?")
and my chatterbot version was 0.8.7
changing as @Jereemi suggested to
chatbot.set_trainer(ChatterBotCorpusTrainer)
chatbot.train("chatterbot.corpus.english")
chatbot.get_response("Hello, how are you today?")
```
does not create an error but does the expected thing
Use instead of trainer = ChatterBotCorpusTrainer(chatbot)
the code trainer = ChatterBotCorpusTrainer(chatbot.storage)
For anyone running into this issue, please make sure that you know which version of ChatterBot you have installed and are using. The alpha version of ChatterBot 1.0 removed the find method.
Also, for some systems, you may need to use the command pip3 to install packages for Python 3. For example:
pip3 install chatterbot==0.8.7
your fix for the example code in the comment does work:
"Use instead of trainer = ChatterBotCorpusTrainer(chatbot)
the code trainer = ChatterBotCorpusTrainer(chatbot.storage)"
However, I'm trying the terminal example (and several similar examples), but none of the examples that use TerminalAdapater for the input actually seem to be reading what I type. They just keep returning the time.
For example that only returns time, try your own terminal_example.py from your examples folder.
Anyone looking for a simple fix:
sudo pip3 uninstall chatterbot
sudo pip3 install chatterbot==1.0.0a1
I had the same "no attribute 'find' symptoms as Jereemi when installing 0.8.7 via 'pip3 install chatterbot. I run python 3.6 and osx 10.13.2.
After applying zasxsaz's fix by updating to 1.0.0a1, I get the following error:
sqlalchemy.exc.OperationalError: (raised as a result of Query-invoked autoflush; consider using a session.no_autoflush block if this flush is occurring prematurely) (sqlite3.OperationalError) table statement has no column named conversation [SQL: 'INSERT INTO statement (text, conversation, in_response_to) VALUES (?, ?, ?)'] [parameters: ('What is AI?', 'training', None)] (Background on this error at: http://sqlalche.me/e/e3q8)
It appears to be a database connection error. Are there any dependencies that I should be aware of - other than: sudo pip3 install chatterbot==1.0.0a1
Still having this issue, any fix?
I proposed a fix but it was refused: https://github.com/gunthercox/ChatterBot/pull/1529
@MartinDelille I think based on what @gunthercox explained, your fix would have broken the example for other users. This example on branch master is for ChatterBot 1.0.0 alpha.
@pylobot Yes he gave me explaination here: https://github.com/gunthercox/ChatterBot/pull/1529#issuecomment-449595270
I'm trying to investigate how to fix training.py but I'm still facing problems.
Same issue here.
sqlalchemy.exc.OperationalError: (raised as a result of Query-invoked autoflush; consider using a session.no_autoflush block if this flush is occurring prematurely) (sqlite3.OperationalError) table statement has no column named conversation [SQL: 'INSERT INTO statement (text, conversation, in_response_to) VALUES (?, ?, ?)'] [parameters: ('What is AI?', 'training', None)] (Background on this error at: http://sqlalche.me/e/e3q8)
I am getting an error while executing first example : https://chatterbot.readthedocs.io/en/stable/examples.html
Traceback (most recent call last):
File "pychatterBotex2.py", line 9, in <module>
chatbot.train([
AttributeError: 'ChatBot' object has no attribute 'train'
I am not very sure where am i doing wrong?
I installed chatterbot with
sudo pip3 install chatterbot==1.0.0a1
HI @citrix123 Please see my response to a related issue here: https://github.com/gunthercox/ChatterBot/issues/1555#issuecomment-453700386 and let me know if you have any questions. You'll just need make a slight modification to your example code.
Traceback (most recent call last):
File "chatbot_train.py", line 16, in
setup()
File "chatbot_train.py", line 11, in setup
chatbot.set_trainer(ListTrainer)
AttributeError: 'ChatBot' object has no attribute 'set_trainer'
@SaralKumarKaviti make sure the chatterbot version is 0.8.7, it works for me
@gunthercox it still doesn't work
ok i want to ask in which version will the ChatterBotCorpusTrainer will work as it doesn't work on the the latest version
I just get this error when i do so:
_sqlalchemy.exc.OperationalError: (sqlite3.OperationalError) cannot change into wal mode from within a transaction (Background on this error at: http://sqlalche.me/e/e3q8)_
I am using corpus 1.1.4 and it works fine for me.
Most helpful comment
@gunthercox I have solved the problem by replacing the following 2 lines:
trainer = ChatterBotCorpusTrainer(bot)
trainer.train("chatterbot.corpus.english")
with the below lines:
bot.set_trainer(ChatterBotCorpusTrainer)
bot.train("chatterbot.corpus.english")
It worked fine. Hope this solution can be of some help to others too:)