Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Spacey "OSError: [E050] Can't find model 'en_core_web_sm'. It doesn't seem to be a Python package or a valid path to a data directory."

Tags:

python

spacy

While working on my first chatbot I am receiving the error in the title of this post. Running Windows 10 using PyCharm (Python 3.7 venv). Tried running my source code below with spacy installed, also tried with spacy legacy and spacy nlp tools with no luck. Greatly appreciate any advice!

Source code:

from chatterbot import ChatBot
from chatterbot.trainers import ListTrainer

import spacy
spacy.load("en_core_web_sm")

my_bot = ChatBot(name='Dalt Wisney', read_only=True,
          logic_adapters=
['chatterbot.logic.TimeLogicAdapter','chatterbot.logic.MathematicalEvaluation',
          'chatterbot.logic.BestMatch'])

small_talk = ['hi there!',
          'hi!',
          'how do you do?',
          'how are you?',
          'i\'m cool.',
          'fine, you?',
          'always cool.',
          'i\'m ok',
          'glad to hear that.',
          'i\'m fine',
          'glad to hear that.',
          'i feel awesome',
          'excellent, glad to hear that.',
          'not so good',
          'sorry to hear that.',
          'what\'s your name?',
          'i\'m DaltWisney. the creative digital assistant. ask me anything.']
math_talk_1 = ['pythagorean theorem', 'a squared plus b squared equals c squared.']
math_talk_2 = ['law of cosines', 'c**2 = a**2 + b**2 - 2 * a * b * cos(gamma)']

list_trainer = ListTrainer(my_bot)

for item in (small_talk, math_talk_1, math_talk_2):
          list_trainer.train(item)

from chatterbot.trainers import ChatterBotCorpusTrainer
corpus_trainer = ChatterBotCorpusTrainer(my_bot)
corpus_trainer.train('chatterbot.corpus.english')

Full error message:

Traceback (most recent call last): File "C:/Users/bronson.benzien/PycharmProjects/pythonProject/Dalt Wisney ChatBot.py", line 5, in spacy.load("en_core_web_sm") File "C:\Users\bronson.benzien\PycharmProjects\pythonProject\venv\lib\site-packages\spacy_init_.py", line 51, in load name, vocab=vocab, disable=disable, exclude=exclude, config=config File "C:\Users\bronson.benzien\PycharmProjects\pythonProject\venv\lib\site-packages\spacy\util.py", line 331, in load_model raise IOError(Errors.E050.format(name=name)) OSError: [E050] Can't find model 'en_core_web_sm'. It doesn't seem to be a Python package or a valid path to a data directory.

Process finished with exit code 1

like image 273
Bronson Benzien Avatar asked Nov 24 '25 07:11

Bronson Benzien


1 Answers

You need to download the language model. Got to the command line and activate your virtual env (venv). Run the following command:

python -m spacy download en_core_web_sm
like image 76
krisograbek Avatar answered Nov 26 '25 20:11

krisograbek