code :
from chatterbot import ChatBot
chatbot = ChatBot(
'Ron Obvious',
trainer='chatterbot.trainers.ChatterBotCorpusTrainer'
)
chatbot.train("chatterbot.corpus.english")
chatbot.get_response("Hello, how are you today?")
error :
python test.py
Traceback (most recent call last):
File "test.py", line 1, in <module>
from chatterbot import ChatBot
ImportError: No module named chatterbot
@harshalgaydhankar which version of chatterbot version are you using currently? To know current version chatterbot use below command.
python -m chatterbot --version
If you are unable to get chatterbot version, try to install chatterbot by using this command. If you get any permission related errors try to append sudo before pip if you are using Linux/Ubuntu Platforms.
pip install --upgrade chatterbot
i met the same problem today, and i had upgraded chatterbot ,but i am unable to get chatterbot version yet. when using "from chatterbot import ChatBot", Python still show importError: No module named chatterbot.
(Windows 10 64bit, python3.5)
I am unable to figure your issue, how are you installing/upgrading chatterbot through virtual enviroment or system level?
Microsoft Windows [version 10.0.14393]
(c) 2016 Microsoft Corporation
C:\WINDOWS\system32>d:
D:\>cd D:\Program Files (x86)\Python35-32\Lib\site-packages
D:\Program Files (x86)\Python35-32\Lib\site-packages>pip install ./chatterbot
Processing d:\program files (x86)\python35-32\lib\site-packages\chatterbot
Requirement already satisfied (use --upgrade to upgrade): ChatterBot==0.7.0 from file:///D:/Program%20Files%20%28x86%29/Python35-32/Lib/site-packages/chatterbot in d:\program files (x86)\python35-32\lib\site-packages
Requirement already satisfied: chatterbot-corpus<1.1.0,>=1.0.0 in d:\program files (x86)\python35-32\lib\site-packages (from ChatterBot==0.7.0)
Requirement already satisfied: jsondatabase<1.0.0,>=0.1.7 in d:\program files (x86)\python35-32\lib\site-packages (from ChatterBot==0.7.0)
Requirement already satisfied: nltk<4.0.0,>=3.2.0 in d:\program files (x86)\python35-32\lib\site-packages (from ChatterBot==0.7.0)
Requirement already satisfied: pymongo<4.0.0,>=3.3.0 in d:\program files (x86)\python35-32\lib\site-packages (from ChatterBot==0.7.0)
Requirement already satisfied: python-twitter<4.0.0,>=3.0.0 in d:\program files (x86)\python35-32\lib\site-packages (from ChatterBot==0.7.0)
Requirement already satisfied: SQLAlchemy<1.2,>=1.1 in d:\program files (x86)\python35-32\lib\site-packages (from ChatterBot==0.7.0)
Requirement already satisfied: ruamel.yaml<=0.15 in d:\program files (x86)\python35-32\lib\site-packages (from chatterbot-corpus<1.1.0,>=1.0.0->ChatterBot==0.7.0)
Requirement already satisfied: six in d:\program files (x86)\python35-32\lib\site-packages (from nltk<4.0.0,>=3.2.0->ChatterBot==0.7.0)
Requirement already satisfied: future in d:\program files (x86)\python35-32\lib\site-packages (from python-twitter<4.0.0,>=3.0.0->ChatterBot==0.7.0)
Requirement already satisfied: requests in d:\program files (x86)\python35-32\lib\site-packages (from python-twitter<4.0.0,>=3.0.0->ChatterBot==0.7.0)
Requirement already satisfied: requests-oauthlib in d:\program files (x86)\python35-32\lib\site-packages (from python-twitter<4.0.0,>=3.0.0->ChatterBot==0.7.0)
Requirement already satisfied: idna<2.6,>=2.5 in d:\program files (x86)\python35-32\lib\site-packages (from requests->python-twitter<4.0.0,>=3.0.0->ChatterBot==0.7.0)
Requirement already satisfied: certifi>=2017.4.17 in d:\program files (x86)\python35-32\lib\site-packages (from requests->python-twitter<4.0.0,>=3.0.0->ChatterBot==0.7.0)
Requirement already satisfied: urllib3<1.22,>=1.21.1 in d:\program files (x86)\python35-32\lib\site-packages (from requests->python-twitter<4.0.0,>=3.0.0->ChatterBot==0.7.0)
Requirement already satisfied: chardet<3.1.0,>=3.0.2 in d:\program files (x86)\python35-32\lib\site-packages (from requests->python-twitter<4.0.0,>=3.0.0->ChatterBot==0.7.0)
Requirement already satisfied: oauthlib>=0.6.2 in d:\program files (x86)\python35-32\lib\site-packages (from requests-oauthlib->python-twitter<4.0.0,>=3.0.0->ChatterBot==0.7.0)
D:\Program Files (x86)\Python35-32\Lib\site-packages>cd..
D:\Program Files (x86)\Python35-32\Lib>cd..
D:\Program Files (x86)\Python35-32>python -m chatterbot --version
D:\Program Files (x86)\Python35-32\python.exe: No module named chatterbot
D:\Program Files (x86)\Python35-32>cd D:\Program Files (x86)\Python35-32\Lib\site-packages
D:\Program Files (x86)\Python35-32\Lib\site-packages>pip install --upgrade chatterbot
Requirement already up-to-date: chatterbot in d:\program files (x86)\python35-32\lib\site-packages
Requirement already up-to-date: nltk<4.0.0,>=3.2.0 in d:\program files (x86)\python35-32\lib\site-packages (from chatterbot)
Requirement already up-to-date: chatterbot-corpus<1.1.0,>=1.0.0 in d:\program files (x86)\python35-32\lib\site-packages (from chatterbot)
Requirement already up-to-date: python-twitter<4.0.0,>=3.0.0 in d:\program files (x86)\python35-32\lib\site-packages (from chatterbot)
Requirement already up-to-date: SQLAlchemy<1.2,>=1.1 in d:\program files (x86)\python35-32\lib\site-packages (from chatterbot)
Requirement already up-to-date: jsondatabase<1.0.0,>=0.1.7 in d:\program files (x86)\python35-32\lib\site-packages (from chatterbot)
Requirement already up-to-date: pymongo<4.0.0,>=3.3.0 in d:\program files (x86)\python35-32\lib\site-packages (from chatterbot)
Requirement already up-to-date: six in d:\program files (x86)\python35-32\lib\site-packages (from nltk<4.0.0,>=3.2.0->chatterbot)
Requirement already up-to-date: ruamel.yaml<=0.15 in d:\program files (x86)\python35-32\lib\site-packages (from chatterbot-corpus<1.1.0,>=1.0.0->chatterbot)
Requirement already up-to-date: future in d:\program files (x86)\python35-32\lib\site-packages (from python-twitter<4.0.0,>=3.0.0->chatterbot)
Requirement already up-to-date: requests in d:\program files (x86)\python35-32\lib\site-packages (from python-twitter<4.0.0,>=3.0.0->chatterbot)
Requirement already up-to-date: requests-oauthlib in d:\program files (x86)\python35-32\lib\site-packages (from python-twitter<4.0.0,>=3.0.0->chatterbot)
Requirement already up-to-date: urllib3<1.22,>=1.21.1 in d:\program files (x86)\python35-32\lib\site-packages (from requests->python-twitter<4.0.0,>=3.0.0->chatterbot)
Requirement already up-to-date: chardet<3.1.0,>=3.0.2 in d:\program files (x86)\python35-32\lib\site-packages (from requests->python-twitter<4.0.0,>=3.0.0->chatterbot)
Requirement already up-to-date: idna<2.6,>=2.5 in d:\program files (x86)\python35-32\lib\site-packages (from requests->python-twitter<4.0.0,>=3.0.0->chatterbot)
Requirement already up-to-date: certifi>=2017.4.17 in d:\program files (x86)\python35-32\lib\site-packages (from requests->python-twitter<4.0.0,>=3.0.0->chatterbot)
Requirement already up-to-date: oauthlib>=0.6.2 in d:\program files (x86)\python35-32\lib\site-packages (from requests-oauthlib->python-twitter<4.0.0,>=3.0.0->chatterbot)
D:\Program Files (x86)\Python35-32\Lib\site-packages>
Then, i met the same problem like@harshalgaydhankar, python3.5 show importError," No module named chatterbot."
just like:
Python 3.5.1 (v3.5.1:37a07cee5969, Dec 6 2015, 01:38:48) [MSC v.1900 32 bit (Intel)] on win32
Type "copyright", "credits" or "license()" for more information.
>>> from chatterbot import ChatBot
Traceback (most recent call last):
File "<pyshell#0>", line 1, in <module>
from chatterbot import ChatBot
ImportError: No module named 'chatterbot'
Can you import _any_ python packages that have been installed?
I'm wondering if this isn't an issue that is specific to ChatterBot.
For example, if you run:
pip install nose --upgrade
and then try to import it:
Python 3.5.1 (v3.5.1:37a07cee5969, Dec 6 2015, 01:38:48) [MSC v.1900 32 bit (Intel)] on win32
Type "copyright", "credits" or "license()" for more information.
>>> import nose
Your were in current chatterbot installation directory, could you try relative import like below?
from .chatterbot import ChatBot
More information available here https://stackoverflow.com/questions/12172791/changes-in-import-statement-python3
i import nose successfully , @gunthercox
and i tried relative import, but also failed, @vkosuri
thanks for your help, i am totally a newcomer to chatterbot and python.
>>> from .chatterbot import ChatBot
Traceback (most recent call last):
File "<pyshell#7>", line 1, in <module>
from .chatterbot import ChatBot
SystemError: Parent module '' not loaded, cannot perform relative import
>>>
Thanks @shashwatbhatt, Another guess could be D:\Program Files (x86)\Python35-32\ is not in system path.
To know system path, try below commands. If D:\Program Files (x86)\Python35-32\ not added to python path, please add it in windows system environment variables.
import sys
print(sys.path)
>>> import sys
>>> print(sys.path)
['', 'D:\\Program Files (x86)\\Python35-32\\Lib\\idlelib', 'D:\\Program Files (x86)\\Python35-
32\\python35.zip', 'D:\\Program Files (x86)\\Python35-32\\DLLs', 'D:\\Program Files (x86)\\Python35-
32\\lib', 'D:\\Program Files (x86)\\Python35-32', 'D:\\Program Files (x86)\\Python35-32\\lib\\site-packages']
>>>
@vkosuri
I am sorry i am unable to figure it your issue on my machine with python 3.4, I see these type issues if you have multiple variants of pythons installed in your machine. Do you have multiple variants of pythons are installed in your machine?
thanks, only python3.5 installed in my PC
What do you get as an output from the command pip freeze ?
my god~~i am so sorry , i made a stupid mistake, after i download the "ChatterBot-master" from git, i used this folder directly.Instead, i should copy the subfolder"chatterbot" in "ChatterBot-master" .
No problem, it happens ¯_(ツ)_/¯
I am facing the same issue while importing the chatterbot . I shall be very thankful if someone can help on this. Chatterbot has successfully been installed using pip install chatterbot but i am unable to import it .Below are the errors i am facing :
import ChatBot
Traceback (most recent call last):
File "
import ChatBot
ModuleNotFoundError: No module named 'ChatBot'
import chatterbot
Traceback (most recent call last):
File "", line 1, in
import chatterbot
File "C:Usersrkuma164AppDataRoamingPythonPython36site-packageschatterbot__init__.py", line 4, in
from .chatterbot import ChatBot
File "C:Usersrkuma164AppDataRoamingPythonPython36site-packageschatterbotchatterbot.py", line 3, in
from chatterbot.logic import LogicAdapter
File "C:Usersrkuma164AppDataRoamingPythonPython36site-packageschatterbotlogic__init__.py", line 1, in
from chatterbot.logic.logic_adapter import LogicAdapter
File "C:Usersrkuma164AppDataRoamingPythonPython36site-packageschatterbotlogiclogic_adapter.py", line 3, in
from chatterbot.search import IndexedTextSearch
File "C:Usersrkuma164AppDataRoamingPythonPython36site-packageschatterbotsearch.py", line 1, in
from chatterbot.conversation import Statement
File "C:Usersrkuma164AppDataRoamingPythonPython36site-packageschatterbotconversation.py", line 1, in
from pytz import UTC
ModuleNotFoundError: No module named 'pytz'
pip install pytz --user
i am not sure if the developer forgets to add it to requirements.txt
It works now .Thank you very very much FinchZ 🥇 . Have a wonderful Day
module not found error coming in idle after successful installation of chatterbot
shousunny i m getting same problem
please help
Just install everything once again and install chatterbot-corpus library first and then install chatterbot libraries
Reinstall chatterbot and see if you are getting any error. In my case , I was getting below error:
Installing collected packages: pyYAML
Found existing installation: PyYAML 3.12
ERROR: Cannot uninstall 'PyYAML'. It is a distutils installed project and thus w
e cannot accurately determine which files belong to it which would lead to only
a partial uninstall.
I searched for all pyYAML files and removed manually. then reinstalled and got below message.
Installing collected packages: pyyaml, mathparse, chatterbot
Successfully installed chatterbot-1.0.5 mathparse-0.1.2 pyyaml-5.1.2
Now I can successfully import it.
Unable to import modules after installing the package..
Successfully installed the package but it is not importing what should i do?
Traceback (most recent call last):
File "chatbot_training.py", line 13, in
message = imput('You: ')
NameError: name 'imput' is not defined
Traceback (most recent call last):
File "chatbot_training.py", line 13, in
message = imput('You: ')
NameError: name 'imput' is not defined
message = input('You':)
It's typo error
Reinstall chatterbot and see if you are getting any error. In my case , I was getting below error:
Installing collected packages: pyYAML
Found existing installation: PyYAML 3.12
ERROR: Cannot uninstall 'PyYAML'. It is a distutils installed project and thus w
e cannot accurately determine which files belong to it which would lead to only
a partial uninstall.
I searched for all pyYAML files and removed manually. then reinstalled and got below message.
Installing collected packages: pyyaml, mathparse, chatterbot
Successfully installed chatterbot-1.0.5 mathparse-0.1.2 pyyaml-5.1.2Now I can successfully import it.
I did the same thing you did and it worked.
I just had to put "sudo" in front and then download it and then on the pycharm he told me to update
(base) D:vs>D:/anaconda/python.exe d:/vs/AI/chatbot1.py
Traceback (most recent call last):
File "d:/vs/AI/chatbot1.py", line 17, in
storage_adapter = "chatterbot.storage.SQLStorageAdapter")
File "D:anacondalibsite-packageschatterbotchatterbot.py", line 28, in __init__
self.storage = utils.initialize_class(storage_adapter, kwargs)
File "D:anacondalibsite-packageschatterbotutils.py", line 33, in initialize_class
return Class(args, *kwargs)
File "D:anacondalibsite-packageschatterbotstoragesql_storage.py", line 20, in __init__
super().__init__(kwargs)
File "D:anacondalibsite-packageschatterbotstoragestorage_adapter.py", line 21, in __init__
'tagger_language', languages.ENG
File "D:anacondalibsite-packageschatterbottagging.py", line 13, in __init__
self.nlp = spacy.load(self.language.ISO_639_1.lower())
File "D:anacondalibsite-packagesspacy__init__.py", line 30, in load
return util.load_model(name, *overrides)
File "D:anacondalibsite-packagesspacyutil.py", line 170, in load_model
return load_model_from_package(name, *overrides)
File "D:anacondalibsite-packagesspacyutil.py", line 190, in load_model_from_package
cls = importlib.import_module(name)
File "D:anacondalibimportlib__init__.py", line 127, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "
File "
File "
ModuleNotFoundError: No module named 'en'
#/libraries we’ll be using. re is the package that handles regular expression in Python. We’ll also be using WordNet from NLTK. WordNet is a lexical database that defines semantical relationships between words. We’ll be using WordNet to build up a dictionary of synonyms to our keywords. This will help us expand our list of keywords without manually having to introduce every possible word a user could use.
import re
from nltk.corpus import wordnet
import nltk
nltk.download('wordnet')
list_words=['hello','timings']
list_syn={}
for word in list_words:
synonyms=[]
for syn in wordnet.synsets(word):
for lem in syn.lemmas():
# Remove any special characters from synonym strings
lem_name = re.sub('[^a-zA-Z0-9 \n\.]', ' ', lem.name())
synonyms.append(lem_name)
list_syn[word]=set(synonyms)
print (list_syn)
Output:
hello
{'hello', 'howdy', 'hi', 'hullo', 'how do you do'}
timings
{'time', 'clock', 'timing'}
keywords={}
keywords_dict={}
keywords['greet']=[]
for synonym in list(list_syn['hello']):
keywords['greet'].append('.\b'+synonym+'\b.')
keywords['timings']=[]
for synonym in list(list_syn['timings']):
keywords['timings'].append('.\b'+synonym+'\b.')
for intent, keys in keywords.items():
# Joining the values in the keywords dictionary with the OR (|) operator updating them in keywords_dict dictionary
keywords_dict[intent]=re.compile('|'.join(keys))
print (keywords_dict)
responses={
'greet':'Hello! How can I help you?',
'timings':'We are open from 9AM to 5PM, Monday to Friday. We are closed on weekends and public holidays.',
'fallback':'I dont quite understand. Could you repeat that?',
}
print ("Welcome to MyBank. How may I help you?")
while (True):
# Takes the user input and converts all characters to lowercase
user_input = input().lower()
# Defining the Chatbot's exit condition
if user_input == 'quit':
print ("Thank you for visiting.")
break
matched_intent = None
for intent,pattern in keywords_dict.items():
# Using the regular expression search function to look for keywords in user input
if re.search(pattern, user_input):
# if a keyword matches, select the corresponding intent from the keywords_dict dictionary
matched_intent=intent
# The fallback intent is selected by default
key='fallback'
if matched_intent in responses:
# If a keyword matches, the fallback intent is replaced by the matched intent as the key for the responses dictionary
key = matched_intent
# The chatbot prints the response that matches the selected intent
print (responses[key])
after execution give the error :
(base) D:vs>D:/anaconda/python.exe d:/vs/AI/chatbot1.py
Traceback (most recent call last):
File "d:/vs/AI/chatbot1.py", line 17, in
storage_adapter = "chatterbot.storage.SQLStorageAdapter")
File "D:anacondalibsite-packageschatterbotchatterbot.py", line 28, in init
self.storage = utils.initialize_class(storage_adapter, kwargs)
File "D:anacondalibsite-packageschatterbotutils.py", line 33, in initialize_class
return Class(args, *kwargs)
File "D:anacondalibsite-packageschatterbotstoragesql_storage.py", line 20, in init
super().init(kwargs)
File "D:anacondalibsite-packageschatterbotstoragestorage_adapter.py", line 21, in init
'tagger_language', languages.ENG
File "D:anacondalibsite-packageschatterbottagging.py", line 13, in init
self.nlp = spacy.load(self.language.ISO_639_1.lower())
File "D:anacondalibsite-packagesspacy_init_.py", line 30, in load
return util.load_model(name, *overrides)
File "D:anacondalibsite-packagesspacyutil.py", line 170, in load_model
return load_model_from_package(name, *overrides)
File "D:anacondalibsite-packagesspacyutil.py", line 190, in load_model_from_package
cls = importlib.import_module(name)
File "D:anacondalibimportlib_init_.py", line 127, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "", line 1006, in _gcd_import
File "", line 983, in _find_and_load
File "", line 965, in _find_and_load_unlocked
ModuleNotFoundError: No module named 'en'
hi l am getting this error after trying to run my chatbot, l installed chatterbot and chatterbot-corpuse successfully
Traceback (most recent call last):
File "C:UsersDellAppDataLocalProgramsPythonPython36-32chatbot 2.0chatbot 2.0.py", line 1, in
from chatterbot import ChatBot
File "C:UsersDellAppDataLocalProgramsPythonPython36-32libsite-packageschatterbot__init__.py", line 4, in
from .chatterbot import ChatBot
File "C:UsersDellAppDataLocalProgramsPythonPython36-32libsite-packageschatterbotchatterbot.py", line 2, in
from chatterbot.storage import StorageAdapter
File "C:UsersDellAppDataLocalProgramsPythonPython36-32libsite-packageschatterbotstorage__init__.py", line 1, in
from chatterbot.storage.storage_adapter import StorageAdapter
File "C:UsersDellAppDataLocalProgramsPythonPython36-32libsite-packageschatterbotstoragestorage_adapter.py", line 3, in
from chatterbot.tagging import PosLemmaTagger
File "C:UsersDellAppDataLocalProgramsPythonPython36-32libsite-packageschatterbottagging.py", line 3, in
import spacy
ModuleNotFoundError: No module named 'spacy'
Most helpful comment
pip install pytz --user
i am not sure if the developer forgets to add it to requirements.txt