有anaconda_python3.7安装pyltp(3.6支持)

anaconda_python3.7安装pyltp(3.6支持)

花费一天时间弄好了pyltp,记录一下,望能帮到你
本机:python 3.7.0 ;anaconda3 ;pycharm
目的:安装pyltp(python3.6环境下)

一、anaconda相关操作

  1. 修改anaconda中conda和pip的源为清华源(prompt面板)
    参考链接
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main/
conda config --set show_channel_urls yes
#一步一步来
  1. anaconda创建虚拟环境
 conda create --name pythonltp36 python=3.6

在这里插入图片描述
检查是否成功(prompt面板):

(base) C:\Users\lenovo>activate pythonltp36

在这里插入图片描述

(pythonltp36) C:\Users\lenovo>python

在这里插入图片描述
上图所示运行环境3.6版本

二、ltp–whl文件

**2.1下载
参考链接-文件来源
轮子下载地址:
链接:https://pan.baidu.com/s/1Jbw6IjVbb-URZCHvh3FNDQ
提取码:i3le

pyltp-0.2.1-cp35-cp35m-win_amd64.whl(python3.5,64位)
pyltp-0.2.1-cp36-cp36m-win_amd64.whl(python3.6,64位)(根据我的编译环境,下载这个)

1.下图 python36rb 等同于 上面所建pythonltp36(为写本次文章专门新建的)
在这里插入图片描述
2.cmd 上图文件夹
在这里插入图片描述
下面两个都可,网上说法不一,自行尝试

pip install pyltp-0.2.1-cp36-cp36m-win_amd64.whl
pip3 install pyltp-0.2.1-cp36-cp36m-win_amd64.whl

在这里插入图片描述

3.下载ltp模型
下图参考链接:https://blog.csdn.net/weixin_44293949/article/details/108631514

在这里插入图片描述

先下载压缩包。其次,替换压缩包里本有的一个子文件 pisrl.model ,修改pisrl.win.model名字为pisrl.model

在这里插入图片描述在这里插入图片描述
在这里插入图片描述

**

三、pycharm

**

下图参考链接,很详细,我就不多说啦
在这里插入图片描述

我弄好后的界面显示:
在这里插入图片描述

四、简单运用

import os
from pyltp import Segmentor
LTP_DIR=r'E:\pyltp\pyltphagongda\ltp_data'  # ltp模型目录的路径
cws_model_path=os.path.join(LTP_DIR,'cws.model') # 分词模型路径,模型名称为`cws.model`
segmentor=Segmentor()            # 初始化实例
segmentor.load(cws_model_path)   # 加载模型
words=segmentor.segment('我还没吃饭你吃饭了吗')   # 分词
print('\t'.join(words))
segmentor.release()       # 释放模型

在这里插入图片描述
在这里插入图片描述

  • 1
    点赞
  • 7
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值