Practical overview
When it fits
Use Pyhanlp when a Python project needs access to HanLP 1.x capabilities for Chinese text, or when a command-line workflow is more convenient than calling the Python interface.
Who it is for
- Python developers adding Chinese-language analysis to text-processing applications.
- Practitioners who need command-line segmentation or dependency parsing.
- Learners exploring NLP tasks through the repository's examples and companion code.
Documented uses
- Segment Chinese text and inspect part-of-speech labels.
- Parse dependency relations in a sentence.
- Extract keywords or generate an automatic summary.
- Call HanLP functionality from Python and, when needed, access lower-level Java classes.
Requirements & limits
The repository identifies the project as open source under the Apache-2.0 license.
- The interface targets HanLP 1.x; the README describes HanLP 2.x as a separate, parallel project.
- The documented installation path installs OpenJDK and Python through conda before installing Pyhanlp with pip.
- The README specifies Python 3.6 or later compatibility and lists Linux, macOS and Windows support.
- Lower-level analyzer access uses Java class paths through JClass, rather than only the common Python convenience interface.
Check current requirements in the official documentation. Source-based guidance does not mean OpenViST has run or independently tested this project.
Install Pyhanlp with conda and pip
Prepare the documented Python and Java prerequisites and install the Pyhanlp package.
Before you start
- Conda
- OpenJDK
- Python 3.8
Steps
Install OpenJDK and Python 3.8 from conda-forge using the README's conda command.
Install Pyhanlp with pip.
Run the hanlp command to check the installation.
Expected outcome
The package is installed and the documented command-line check can be run.
Guide limitations
- The README notes that automatic setup may fail because of network or other issues and points to manual configuration and a Windows guide.
Segment Chinese text with the command line
Use the documented interactive segmentation command to obtain segmented output.
Before you start
- An installed Pyhanlp environment with the hanlp command available
Steps
Run hanlp segment.
Enter a Chinese sentence and press return.
Read the segmentation result and its displayed part-of-speech labels.
Expected outcome
HanLP 1.x returns segmented text in the command-line session.
Guide limitations
- This recipe covers the documented interactive workflow; the README also describes redirected input and output separately.
Sources & review
Source record details
- Source availability
- Active
- Sources checked
- 15 October 2026
- Original website title
- hankcs/pyhanlp · Official homepage title · retained in its source language

