spacy和en安装

参考:https://www.zhihu.com/question/56095738/answer/283999308
安装spacy en_core_web_sm报错
raise ConnectionError(e, request=request)
requests.exceptions.ConnectionError: HTTPSConnectionPool(host=‘raw.githubusercontent.com’, port=443): Max retries exceeded with url: /explosion/spacy-models/master/shortcuts-v2.json (Caused by NewConnectionError(’: Failed to establish a new connection: [Errno 11004] getaddrinfo failed’,))
无论是装spacy还是en的库都会报这个错(anaconda prompt)。。。后来用pycharm装上了spacy(2.3.0),也用同样方法装了en, en_core_web_sm之类,但是还是会报错:no module named en

后来我从github上通过pip安装en_core_web_sm,由于我没有找到2.3.0版本,只能装了2.1.0
pip --default-timeout=10000 install https://github.com/explosion/spacy-models/releases/download/en_core_web_sm-2.1.0/en_core_web_sm-2.1.0.tar.gz
spacy和en安装_第1张图片
然而:
spacy和en安装_第2张图片
似乎是在说版本不对应。。。。,而且pycharm依然报错No module named ‘en’
可算让我给找着了:https://github.com/explosion/spacy-models/releases/tag/en_core_web_sm-2.3.0
spacy和en安装_第3张图片

pip --default-timeout=10000 install https://github.com/explosion/spacy-models/releases/download/en_core_web_sm-2.3.0/en_core_web_sm-2.3.0.tar.gz

安装
spacy和en安装_第4张图片
测试:

import spacy
spacy.load("en_core_web_sm")

在这里插入图片描述
使用,参考:https://blog.csdn.net/lrt366/article/details/90269582
注意,在torchtext中使用spacy时,由于field的默认属性是tokenizer_language=‘en’

TEXT = torchtext.data.Field(tokenize='spacy',  tokenizer_language='en_core_web_sm')

另附安装en_core_web_md的方式:

pip --default-timeout=10000 install https://github.com/explosion/spacy-models/releases/download/en_core_web_md-2.3.0/en_core_web_md-2.3.0.tar.gz

你可能感兴趣的:(python)