I am trying to buid a chatbot. so i installed chatterbot package. the python code is following:
from chatterbot import TalkWithCleverbot
talk = TalkWithCleverbot()
talk.begin()
but i am getting the following error:
Traceback (most recent call last):
File "C:\Users\JERIN\Desktop\bottobot.py", line 2, in <module>
talk = TalkWithCleverbot()
File "C:\Python27\lib\site-packages\chatterbot\__init__.py", line 157, in __init__
super(TalkWithCleverbot, self).__init__()
File "C:\Python27\lib\site-packages\chatterbot\__init__.py", line 4, in __init__
from jsondb.db import Database
ImportError: No module named db
I tried installing jsondb and db packages, but there is no good. Please help me
Your error is highlighting the issue -- there's no db
object to import from jsondb
for the call in __init__.py
.
def __init__(self, name="bot", logging=True):
from jsondb.db import Database
^^ this doesn't exist
I found the source for the 'ChatterBot' module on GitHub and it appears that the 'jsondb' that the author is importing is not the one you'd get if you installed from pip. Instead, the author is expecting you to use his jsondb module that can be found on GitHub.
You can likely resolve this by uninstalling the jsondb that you retreived from pip:
pip uninstall jsondb
and installing the ChatterBot author's jsondb module:
pip install git+https://github.com/gunthercox/jsondb.git
You ran into this error because the ChatterBot author is assuming that you had his package named jsondb installed and did not include the dependency in a typical manner.