首先遇到这个错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.
大概是要load('en'),但是没有,那就下载。可是按照下载命令
python3 -m spacy download en
不行啊,又报这个错
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('<urllib3.connection.HTTPSConnection object at 0x7fd6517b6cc0>: Failed to establish a new connection: [Errno 111] Connection refused',))
好的吧,那我就离线安装,
安装成功之后,跑代码又报错 sre_constants.error: bad escape \p at position 257,
错误复制一搜,发现说是不是最新的,得嘞,我就搜啊搜找啊找,终于成功了。
来自这位哥们的博客https://blog.csdn.net/kunAUGUST/article/details/106841865
在这感谢这位兄弟,相逢何必曾相识!
两个安装命令,我需要的是前面这一个
en_core_web_sm
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
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