Install pyhanlp toolkit in python3.6 under mac environment

pyhanlp is a natural language processing toolkit developed based on Java. Since my entire project is written based on Python, I stepped on a lot of pits when installing pynlp, and recorded it as a reference for other people in need.

1. Upgrade TensorFlow to the specified version

pip install tensorflow==version number -i https://pypi.doubanio.com/simple/ --trusted-host pypi.doubanio.com

pyhanlp requires TensorFlow version 2.0, so version 1.0 needs to be upgraded. Remember to use Douban mirror source will be much faster.

2. Configure conda mirror source

Stepped on a lot of pits in this step, enter the anaconda configuration file

vi /Users/limingyu/.condarc

The final successful configuration is as follows

channels:
  - http://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/
  - http://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main/
ssl_verify: true
show_channel_urls: true

Note that http is not https, and /free and /main of the Tsinghua mirror source must be added, otherwise there will be some dependencies that are not available

3. Upgrade conda

If the following error occurs

RemoveError: 'requests' is a dependency of conda and cannot be removed

It is because the version of conda is too old. Some packages installed by pip have a little problem. The solution is also very simple, just upgrade conda

conda update conda

4. Install gcc with conda

conda install gcc

5. Install jpype1 with conda

conda install -c conda-forge jpype1

6. Finally you can install pyhanlp directly

pip install pyhanlp

Got it, finally verify it in Python

from pyhanlp import *

 

Guess you like

Origin blog.csdn.net/qq_22472047/article/details/104474561