在mac上安装python版的hanlp/JPype1

安装python版的hanlp时老是出错,直接 pip install pyhanlp,会出现这个错误:

In file included from native/common/jp_method.cpp:17:
native/common/include/jpype.h:56:10: fatal error: 'map' file not found
#include <map>
^~~~~
1 warning and 1 error generated.
error: command 'gcc' failed with exit status 1

最后的解决办法是参考:

https://stackoverflow.com/questions/54016317/error-in-installing-jpype1-in-python-3-7-on-mac-os-10-14-2

先用conda安装gcc:

  conda install gcc

再用conda安装jpype1:

  conda install -c conda-forge jpype1

最后终于可以直接安装pyhanlp了

  pip install pyhanlp

搞定

在python里验证一下:

  from pyhanlp import *

然后会自动下载相关的库

 

posted @ 2019-07-09 16:41  sbj123456789  阅读(2013)  评论(0编辑  收藏  举报