KoNLPy (Korean Natural Language Processing in Python) is a Python package designed for Korean text analysis. It provides a consistent API for various popular Korean NLP tools written primarily in Java, including Hannanum, Kkma, Komoran, Mecab (unsupported on Windows), and Okt (Open Korean Text). The current version is 0.6.0, and while its release cadence is irregular, the library is actively maintained to integrate new upstream NLP tools.
pip install konlpyVerified import paths — ran on the pinned version, not inferred.
This quickstart demonstrates basic Korean text processing using the `Okt` (Open Korean Text) tagger, including morphological analysis, part-of-speech tagging, and noun extraction. Ensure a JDK is installed and configured for this to run.
Install a JDK 8+ (e.g., OpenJDK). Set the `JAVA_HOME` environment variable to your JDK installation directory and add `%JAVA_HOME%\bin` (Windows) or `$JAVA_HOME/bin` (Linux/macOS) to your system's PATH. Restart your terminal/IDE after configuration.
On Windows, avoid using `Mecab` and opt for alternative taggers like `Okt`, `Komoran`, `Kkma`, or `Hannanum`. On Linux/macOS, follow the specific system-level installation instructions (e.g., `pip install python-mecab-ko` and `mecab-ko-dic`) provided on the KoNLPy GitHub repository.
Increase the JVM's maximum heap space by setting the `_JAVA_OPTIONS` environment variable before running your Python script. For example, `export _JAVA_OPTIONS="-Xmx4g"` (Linux/macOS) or `set _JAVA_OPTIONS="-Xmx4g"` (Windows) will allocate 4GB. Adjust the `Xmx` value as needed.
Install JDK 8 or higher (e.g., OpenJDK). Set the `JAVA_HOME` environment variable to the root directory of your JDK installation (e.g., `C:\Program Files\Java\jdk-11` or `/usr/lib/jvm/java-11-openjdk`). Add the `bin` subdirectory of your JDK (`%JAVA_HOME%\bin` or `$JAVA_HOME/bin`) to your system's PATH environment variable. Restart your terminal/IDE.
If on Windows, consider using `Okt`, `Komoran`, `Kkma`, or `Hannanum` instead of `Mecab`. On Linux/macOS, ensure Mecab and its dictionary (`mecab-ko-dic`) are correctly installed by following specific instructions for your OS, which typically involves installing `python-mecab-ko`.
Increase the JVM's maximum heap size. You can do this by setting the `_JAVA_OPTIONS` environment variable before running your Python script. For example, to allocate 4GB of memory, use `export _JAVA_OPTIONS="-Xmx4g"` on Linux/macOS or `set _JAVA_OPTIONS="-Xmx4g"` on Windows.
Ensure you import the tagger class correctly. The standard way is `from konlpy.tag import Okt` and then `okt = Okt()`. Alternatively, you can import the submodule as `from konlpy import tag` and then use `tagger = tag.Okt()`.
No dependency data recorded yet.