简体   繁体   English

AttributeError:模块“spacy”没有属性“load”

[英]AttributeError: module 'spacy' has no attribute 'load'

import spacy nlp = spacy.load('en_core_web_sm')导入 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')文件“C:\Users\PavanKumar.spyder-py3\ExcelML.py”,第 27 行,在 nlp = spacy.load('en_core_web_sm')

AttributeError: module 'spacy' has no attribute 'load' AttributeError:模块“spacy”没有属性“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.尝试再次安装 spacy,我遇到了同样的问题,在运行conda install spacy并重新启动我的笔记本 kernel 后它工作了。 For the complete installation documentation check the spacy official website: spacy documentation完整的安装文档请查看 spacy 官网: spacy 文档

Don't name the file spacy.py, it will create conflict.不要将文件命名为 spacy.py,它会产生冲突。

I had the same problem, and it turned out the error was caused by naming the file 'spacy', apparently it creates a naming conflict.我遇到了同样的问题,结果发现错误是由命名文件“spacy”引起的,显然它会产生命名冲突。 In Python distinctive files are modules, and therefore by naming it 'spacy', you overwrite the file and import itself.在 Python 中,独特的文件是模块,因此通过将其命名为“spacy”,您将覆盖文件并导入自身。 Consequently, you should not name your files with package names and they will work well.因此,您不应该使用 package 名称命名您的文件,它们会很好地工作。 Once I renamed the file into something else, it worked flawlessly.一旦我将文件重命名为其他文件,它就可以完美运行。 在此处输入图像描述

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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