Chatterbot: ImportError: cannot import name 'import_module'

Created on 1 Dec 2016  路  8Comments  路  Source: gunthercox/ChatterBot

I did a simple script follow the tutorial but got this error. Any suggestion?
Thanks

python chat.py
Traceback (most recent call last):
File "chat.py", line 1, in
from chatterbot import ChatBot
File "/Users/Hiruma/MyWorkSpace/GitHub/tzchatbot/env/lib/python3.5/site-packages/chatterbot/__init__.py", line 4, in
from .chatterbot import ChatBot
File "/Users/Hiruma/MyWorkSpace/GitHub/tzchatbot/env/lib/python3.5/site-packages/chatterbot/chatterbot.py", line 4, in
from .logic import MultiLogicAdapter
File "/Users/Hiruma/MyWorkSpace/GitHub/tzchatbot/env/lib/python3.5/site-packages/chatterbot/logic/__init__.py", line 1, in
from .logic_adapter import LogicAdapter
File "/Users/Hiruma/MyWorkSpace/GitHub/tzchatbot/env/lib/python3.5/site-packages/chatterbot/logic/logic_adapter.py", line 3, in
from chatterbot.utils import import_module
ImportError: cannot import name 'import_module'

All 8 comments

Go to /Users/Hiruma/MyWorkSpace/GitHub/tzchatbot/env/lib/python3.5/site-packages/chatterbot/

If you see a directory named utils delete it.
Also if you see a directory named adapters delete it.

I had a similar issue recently. For some reason pip appears to be adding cached outdated modules from the previous version when ChatterBot gets upgraded.

In Ubuntu Linux 14.04.5 desktop, the upper two directories utils and adapters is located in /usr/local/lib/python2.7/dist-packages/chatterbot, delete it and it will work.

@gunthercox this error i have seen when i have installed chatterbot from pip install chatterbot may be pip zip file cached these files while uploading into pypi server.

@vkosuri I thought this might be the case as well. I checked out the zip file that pypi has stored for the 0.5 release and all of the files appear to be correct.

I did find that deleting the /build directory in my ChatterBot directory locally corrected the issue for me.

sameerror problem

from chatterbot import Chatbot
Traceback (most recent call last):
File "", line 1, in
ImportError: cannot import name 'Chatbot'
I am using python3

@mohitgoyal001, Like most programming languages, Python imports are case-sensitive. Chatbot should be ChatBot in your import.

Thanks.. @gunthercox it works.

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

Was this page helpful?
0 / 5 - 0 ratings