欢迎来到尧图网

客户服务 关于我们

您的位置:首页 > 健康 > 美食 > python安装spacy3.8.3对应的版本zh_core_web_sm3.8.0

python安装spacy3.8.3对应的版本zh_core_web_sm3.8.0

2025/2/25 18:09:54 来源:https://blog.csdn.net/yanhuatangtang/article/details/145820624  浏览:    关键词:python安装spacy3.8.3对应的版本zh_core_web_sm3.8.0

这次是在visual studio使用python处理一些语言,第一次安装语言包,费了一些周折,记录一下

1.安装python

手动安装了版本3.10,后续又安装了visual studio,发现,手动安装的python中的pip在visual studio内部无法使用,即使已经添加了环境变量,后续在visual studio更新中,重新选择了安装python的相关库,选择了自带的python3.9,pip使用没有问题。

2.安装spacy

使用了python环境pip install spacy,在powershell中查看spacy的版本,可以看出版本为3.8.3

PS D:\Program Files (x86)\Python39_64> pip show spacy
Name: spacy
Version: 3.8.3
Summary: Industrial-strength Natural Language Processing (NLP) in Python
Home-page: https://spacy.io
Author: Explosion

3.继续安装zh_core_web_sm,使用命令pip install zh_core_web_sm

1)显示失败,看来自动安装无法成功

PS D:\Program Files (x86)\Python39_64> pip install zh_core_web_sm
Defaulting to user installation because normal site-packages is not writeable
ERROR: Could not find a version that satisfies the requirement zh_core_web_sm (from versions: none)
ERROR: No matching distribution found for zh_core_web_sm

2)尝试离线安装,但是要注意spacy的版本跟zh_core_web_sm,符合即使安装成功后,也无法使用,不然会报一些奇怪的错误。

找到官网Models & Languages · spaCy Usage Documentation (https://spacy.io/usage/models)点击Language support,找到Chinese,点击 4 packages ,选择以zh_core_web_sm,点击“RELEASE DETAILS”:我选择的是zh_core_web_sm-3.8.0版本,从图中可以看出与我的spacy3.8.3是对应的,点击downloads,存放到本地。

3)安装,记录中zh_core_web_sm-3.8.0存放的位置,使用代码安装:pip install D:\ProgramData\download\zh_core_web_sm-3.8.0-py3-none-any.whl

PS D:\Program Files (x86)\Microsoft Visual Studio\Shared\Python39_64> pip install D:\ProgramData\download\zh_core_web_sm-3.8.0-py3-none-any.whl
Defaulting to user installation because normal site-packages is not writeable
Processing d:\programdata\download\zh_core_web_sm-3.8.0-py3-none-any.whl
Collecting spacy-pkuseg<2.0.0,>=1.0.0 (from zh-core-web-sm==3.8.0)Downloading spacy_pkuseg-1.0.0-cp39-cp39-win_amd64.whl.metadata (13 kB)
Requirement already satisfied: srsly<3.0.0,>=2.3.0 in c:\users\administrator\appdata\roaming\python\python39\site-packages (from spacy-pkuseg<2.0.0,>=1.0.0->zh-core-web-sm==3.8.0) (2.5.1)
Requirement already satisfied: numpy<3.0.0,>=2.0.0 in c:\users\administrator\appdata\roaming\python\python39\site-packages (from spacy-pkuseg<2.0.0,>=1.0.0->zh-core-web-sm==3.8.0) (2.0.2)
Requirement already satisfied: catalogue<2.1.0,>=2.0.3 in c:\users\administrator\appdata\roaming\python\python39\site-packages (from srsly<3.0.0,>=2.3.0->spacy-pkuseg<2.0.0,>=1.0.0->zh-core-web-sm==3.8.0) (2.0.10)
Downloading spacy_pkuseg-1.0.0-cp39-cp39-win_amd64.whl (2.4 MB)---------------------------------------- 2.4/2.4 MB 819.4 kB/s eta 0:00:00
Installing collected packages: spacy-pkuseg, zh-core-web-sm
Successfully installed spacy-pkuseg-1.0.0 zh-core-web-sm-3.8.0

显示安装成功

4)测试一下:

import spacy# 加载中文模型
nlp = spacy.load("zh_core_web_sm")doc = nlp("第一个处理中文语言")print(doc.text)for token in doc:print(token.text, token.pos_, token.dep_)

没有报错,显示如下:

接下来可以处理代码了

版权声明:

本网仅为发布的内容提供存储空间,不对发表、转载的内容提供任何形式的保证。凡本网注明“来源:XXX网络”的作品,均转载自其它媒体,著作权归作者所有,商业转载请联系作者获得授权,非商业转载请注明出处。

我们尊重并感谢每一位作者,均已注明文章来源和作者。如因作品内容、版权或其它问题,请及时与我们联系,联系邮箱:809451989@qq.com,投稿邮箱:809451989@qq.com

热搜词