简体   繁体   English

ImportError:使用chatterbot时没有名为db的模块

[英]ImportError: No module named db when using chatterbot

I am trying to buid a chatbot. 我正在尝试建立一个聊天机器人。 so i installed chatterbot package. 所以我安装了chatterbot包。 the python code is following: python代码如下:

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. 我尝试安装jsondb和db软件包,但没有好处。 Please help me 请帮我

Your error is highlighting the issue -- there's no db object to import from jsondb for the call in __init__.py . 您的错误突出显示了问题 - 没有db对象可以从jsondb导入__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 . 在GitHub上找到了'ChatterBot '模块的源代码,看来作者导入的'jsondb'不是你从pip安装时获得的'jsondb'。 Instead, the author is expecting you to use his jsondb module that can be found on GitHub. 相反,作者希望您使用可以在GitHub上找到的 他的 jsondb模块。

You can likely resolve this by uninstalling the jsondb that you retreived from pip: 您可以通过卸载从pip中检索到的jsondb来解决此问题:

pip uninstall jsondb

and installing the ChatterBot author's jsondb module: 并安装ChatterBot作者的jsondb模块:

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. 您遇到此错误是因为ChatterBot作者假设您安装名为jsondb的软件包,并且没有以典型方式包含依赖项。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM