HanLP versions

Fig. 1 Choose your HanLP version

Install RESTful Packages

Downloads Downloads Downloads

For beginners, the recommended RESTful packages are easier to start with. The only requirement is an auth key. We officially released the following language bindings:


pip install hanlp_restful


See Golang instructions.

Install Native Package

Downloads Downloads Downloads

The native package running locally can be installed via pip.

pip install hanlp

HanLP requires Python 3.6 or later. GPU/TPU is suggested but not mandatory. Depending on your preference, HanLP offers the following flavors:




This installs the default version which delivers the most commonly used functionalities. However, some heavy dependencies like TensorFlow are not installed.


For experts who seek to maximize the efficiency via TensorFlow and C++ extensions, pip install hanlp[full] installs every dependency HanLP will use in production. hanlp[full] requires Python<=3.8 due to tensorflow==2.3.0, which can be easily installed through conda: conda install python=3.8 -y

Install Models

In short, you don’t need to manually install any model. Instead, they are automatically downloaded to a directory called HANLP_HOME when you call hanlp.load. Occasionally, some errors might occur the first time you load a model, in which case you can refer to the following tips.

Download Error

If the auto-download fails, you can either:

  1. Retry as our file server might be busy serving users from all over the world.

  2. Follow the message on your terminal, which often guides you to manually download a zip file to a particular path.

  3. Use a mirror site which could be faster and stabler in your region.

Server without Internet

If your server has no Internet access at all, just debug your codes on your local PC and copy the following directories to your server via a USB disk.

  1. ~/.hanlp: the home directory for HanLP models.

  2. ~/.cache/huggingface: the home directory for Hugging Face 🤗 Transformers.

Import Error

Some TensorFlow/fastText models will ask you to install the missing TensorFlow/fastText modules, in which case you’ll need to install the full version:

pip install hanlp[full]