Rafid Haque
Rafid Haque

Reputation: 15

Can't figure out this problem of Chatterbot

I am currently using elementary OS and I am trying to figure out how to use Chatterbot Library in python.

I have installed the chatterbot library with:

sudo pip3 install chatterbot

I have also installed chatterbot-corpus:

pip install chatterbot-corpus

when i try to run this code with chatterbot:

from chatterbot import ChatBot
from chatterbot.trainers import ListTrainer

# Create a new chat bot named Charlie
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)

it shows this error message:

Traceback (most recent call last):
  File "/home/johndoe/chat.py", line 1, in <module>
    from chatterbot import ChatBot
  File "/usr/local/lib/python3.6/dist-packages/chatterbot/__init__.py", line 4, in <module>
    from .chatterbot import ChatBot
  File "/usr/local/lib/python3.6/dist-packages/chatterbot/chatterbot.py", line 2, in <module>
    from chatterbot.storage import StorageAdapter
  File "/usr/local/lib/python3.6/dist-packages/chatterbot/storage/__init__.py", line 1, in <module>
    from chatterbot.storage.storage_adapter import StorageAdapter
  File "/usr/local/lib/python3.6/dist-packages/chatterbot/storage/storage_adapter.py", line 3, in <module>
    from chatterbot.tagging import PosHypernymTagger
  File "/usr/local/lib/python3.6/dist-packages/chatterbot/tagging.py", line 4, in <module>
    from chatterbot.tokenizers import get_sentence_tokenizer
  File "/usr/local/lib/python3.6/dist-packages/chatterbot/tokenizers.py", line 4, in <module>
    from chatterbot.corpus import load_corpus, list_corpus_files
  File "/usr/local/lib/python3.6/dist-packages/chatterbot/corpus.py", line 5, in <module>
    from chatterbot_corpus.corpus import DATA_DIRECTORY
ModuleNotFoundError: No module named 'chatterbot_corpus

Tried this solution from web: https://github.com/gunthercox/ChatterBot/issues/833

did not work.

How do I solve this?Screenshot of my Code

Upvotes: 1

Views: 2132

Answers (3)

SBMVNO
SBMVNO

Reputation: 642

I would like to provide my answer in 2023 after many tries.

conda create --name test_chatbot python=3.7.3
conda activate test_chatbot
pip3 install ChatterBot2
pip3 install spacy==2.3.5
python -m spacy download en_core_web_sm

Upvotes: 1

Omar Wael
Omar Wael

Reputation: 11

You can install chatterbot2 instead:

pip install ChatterBot2

Upvotes: 1

Thanasis Saxanidis
Thanasis Saxanidis

Reputation: 141

I suggest using pip3 install chatterbot-corpus I think you installed chatterbot on python3 and chatterbot-corpus on python2

Upvotes: 4

Related Questions