简体   繁体   中英

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 nlp = spacy.load('en_core_web_sm')

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

Can anyone suggest me a solution?

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

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

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. 在此处输入图像描述

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM