Arvind
Arvind

Reputation: 91

AttributeError: module 'spacy' has no attribute 'load'

import spacy
nlp = spacy.load('en_core_web_sm')

**Error:** Traceback (most recent call last):

  File "C:\Users\PavanKumar\.spyder-py3\ExcelML.py", line 27, in <module>
    nlp = spacy.load('en_core_web_sm')

AttributeError: module 'spacy' has no attribute 'load'

Can anyone suggest me a solution?

Upvotes: 8

Views: 11683

Answers (3)

I had the same problem, and it turned out the error was caused by naming the file 'spacy', apparently it creates a naming conflict. In Python distinctive files are modules, and therefore by naming it 'spacy', you overwrite the file and import itself. Consequently, you should not name your files with package names and they will work well. Once I renamed the file into something else, it worked flawlessly. enter image description here

Upvotes: 0

K. Mitra
K. Mitra

Reputation: 613

Don't name the file spacy.py, it will create conflict.

Upvotes: 38

Khaled.
Khaled.

Reputation: 59

Try installing spacy again, I had the same problem, after running conda install spacy and restarting my notebook kernel it worked. For the complete installation documentation check the spacy official website: spacy documentation

Upvotes: 3

Related Questions