hanlp的安装问题

安装hanlp的时候遇到一些问题
简单记录

github官方文档的安装:
https://github.com/hankcs/pyhanlp

!conda install -c conda-forge openjdk python=3.8 jpype1=0.7.0 -y -c https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/
!pip install pyhanlp 

但是如果你的电脑缺少java,则需要:

!apt-get update
!apt-get install openjdk-8-jdk -y

另外在下载模型文件的时候,网速惊人的慢:

下载 https://file.hankcs.com/hanlp/data-for-1.7.5.zip 到 /opt/conda/lib/python3.7/site-packages/pyhanlp/static/data-for-1.8.3.zip

手动的话,下载了https://file.hankcs.com/hanlp/data-for-1.7.5.zip 之后需要改名字

最后可以测试一下:

from pyhanlp import *
print(HanLP.parseDependency("徐先生还具体帮助他确定了把画雄鹰、松鼠和麻雀作为主攻目标。"))

猜你喜欢

转载自blog.csdn.net/sinat_26917383/article/details/127927703