在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 *

然后會自動下載相關的庫

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM