我正在尝试在jupyter笔记本中加载“ en”以防伪造,但遇到以下错误。我遵循了先前线程中介绍的步骤,但无济于事。
命令从终端成功运行,但是对jupyter的sys.path和sys.executable的修改也没有成功。我正在使用python3.7。
我对jupyter / python还是很陌生,因此,我感谢所有建议。
我已经包含了第3行和第4行,这是该站点上其他各种答案所建议的,但是相同的错误仍然存在如下:
1. import spacy
2. import sys
3. !python3 -m spacy validate
4. !python3 -m spacy download en
5. nlp = spacy.load('en')
当我将第5行替换为:
nlp = spacy.load('en_core_web_sm')
我在https://github.com/explosion/spaCy/issues/3102中遇到了同样的问题,但是那里的解决方案可以像LINE3一样进行验证(看起来不错)。
这是第3、4和5行的输出,显示该模型有效,已下载,但错误仍然存在
LINE3输出:
✔ Loaded compatibility table
====================== Installed models (spaCy v2.1.4) ======================
ℹ spaCy installation:
/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/spacy-2.1.4-py3.7-macosx-10.9-x86_64.egg/spacy
TYPE NAME MODEL VERSION
package en-core-web-sm en_core_web_sm 2.1.0 ✔
link en en_core_web_sm 2.1.0 ✔
LINE4和LINE5输出:
Requirement already satisfied: en_core_web_sm==2.1.0 from https://github.com/explosion/spacy-models/releases/download/en_core_web_sm-2.1.0/en_core_web_sm-2.1.0.tar.gz#egg=en_core_web_sm==2.1.0 in /Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages (2.1.0)
You are using pip version 19.0.1, however version 19.1.1 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.
✔ Download and installation successful
You can now load the model via spacy.load('en_core_web_sm')
✔ Linking successful
/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/en_core_web_sm
-->
/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/spacy-2.1.4-py3.7-macosx-10.9-x86_64.egg/spacy/data/en
You can now load the model via spacy.load('en')
---------------------------------------------------------------------------
OSError Traceback (most recent call last)
<ipython-input-11-89c4b06ef071> in <module>
1 get_ipython().system('python3 -m spacy download en')
----> 2 spacy.load('en')
/usr/local/lib/python3.7/site-packages/spacy/__init__.py in load(name, **overrides)
25 if depr_path not in (True, False, None):
26 deprecation_warning(Warnings.W001.format(path=depr_path))
---> 27 return util.load_model(name, **overrides)
28
29
/usr/local/lib/python3.7/site-packages/spacy/util.py in load_model(name, **overrides)
134 elif hasattr(name, "exists"): # Path or Path-like to model data
135 return load_model_from_path(name, **overrides)
--> 136 raise IOError(Errors.E050.format(name=name))
137
138
OSError: [E050] Can't find model 'en'. It doesn't seem to be a shortcut link, a Python package or a valid path to a data directory.
谢谢!