Registry / data / iso639-lang

iso639-lang

JSON →
library2.6.3pypypi✓ verified 85d ago

iso639-lang is a fast, comprehensive Python library for working with ISO 639 language codes and information. It provides access to language data across ISO 639-1, -2, and -3 standards. The library is actively maintained with frequent updates, often tied to new releases of the ISO 639-3 tables by SIL, and is currently at version 2.6.3.

pip install iso639-lang
INSTALL
IMPORT
SIG · ISO639-LANG
I
iso639-lang
datapythonv2.6.3
Install
1.6s avg
Import
160ms
Disk
18MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v2.6.3 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
py 3.103.920 runs
installs and imports cleanly · install 0.0s · import 0.172s · 19.7MB
glibc
py 3.103.920 runs
installs and imports cleanly · install 1.6s · import 0.148s · 20MB
18MB installed
● package 18MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

Lang
from iso639 import Lang
from iso639_lang import Lang
The PyPI package name is 'iso639-lang', but the top-level module is 'iso639'.
languages
from iso639 import languages
A pre-populated list of all Lang objects.
is_language
from iso639 import is_language
A utility function to validate language identifiers or names.

Demonstrates how to import the `Lang` class, create instances using various ISO 639 identifiers or English names, access language properties, and use the `is_language` validator. It also shows how to find a language from the pre-populated `languages` list.

from iso639 import Lang, languages, is_language # Get a language by its identifier (ISO 639-1, -2, -3) lang_en = Lang('en') print(f"ISO 639-1: {lang_en.part1}, Name: {lang_en.name}") lang_deu = Lang(part2b='deu') # Using specific part print(f"ISO 639-2 (bibliographic): {lang_deu.part2b}, Name: {lang_deu.name}") lang_ara = Lang('ara') print(f"ISO 639-3: {lang_ara.part3}, Name: {lang_ara.name}, Scope: {lang_ara.scope}, Type: {lang_ara.type}") # Find a language by its English name (case-insensitive) lang_french = Lang('French') print(f"French language: {lang_french.name} ({lang_french.part1})") # Check if a string is a valid language identifier or name print(f"'eng' is a language: {is_language('eng')}") print(f"'invalidcode' is a language: {is_language('invalidcode')}") # Iterate through all languages # For performance, avoid loading all languages into memory if not needed # for lang in languages: # if lang.part1 == 'es': # print(f"Found Spanish: {lang.name}") # break
Debug
Known issues
breakingPython 3.8 support was removed in version 2.6.0. Users on Python 3.8 or older will need to upgrade their Python interpreter or pin `iso639-lang` to `<2.6.0`.
fix
Upgrade Python to 3.9 or newer. If unable, specify `iso639-lang<2.6.0` in your `requirements.txt` or `pyproject.toml`.
affects: >=2.6.0
breakingThe `Lang` constructor's argument handling changed significantly in v2.4.0. It no longer accepts multiple positional arguments (e.g., `Lang('eng', 'english')`) or arbitrary keyword arguments (e.g., `Lang(name='English')`). While v2.4.2 partially rolled back an unintended 'single positional argument' constraint, the general principle is to use one positional argument for an identifier/name, or one specific `partX` keyword argument.
fix
Initialize `Lang` with a single positional argument (e.g., `Lang('eng')`) or a single `partX` keyword argument (e.g., `Lang(part1='en')`). Do not combine multiple identifiers or use non-specific keyword arguments like `name`.
affects: >=2.4.0
deprecatedThe ISO 639-1 identifier `bh` for 'Bihari Languages' was deprecated by ISO and removed from the library's data files. While `iso639-lang` v2.5.0 explicitly marked it as deprecated, the data itself was updated in v2.4.0.
fix
Avoid using `bh` as an identifier. For specific Bihari languages, use their respective ISO 639-3 codes (e.g., `bho` for Bhojpuri, `mai` for Maithili).
affects: >=2.4.0
gotchaAccessing language information for performance: While `from iso639 import languages` provides a comprehensive list of `Lang` objects, iterating through it for lookup can be slow due to its size. For frequent lookups, consider pre-filtering or using `Lang('identifier')` directly, which leverages an optimized internal lookup.
fix
For specific language lookups, prefer `Lang('your_identifier')`. Only iterate `languages` if you need to perform operations on the entire dataset or require filtering beyond direct identifier/name access.
affects: all
Errors
Common errors & fixes
ImportError: cannot import name 'Lang' from 'iso639_lang'
Attempting to import from the PyPI package name (`iso639_lang`) instead of the actual module name (`iso639`).
fix
Change your import statement to `from iso639 import Lang` (or other symbols like `languages`, `is_language`).
TypeError: Lang() takes 1 positional argument but 2 were given
You are passing multiple positional arguments to the `Lang` constructor, which is no longer supported since version 2.4.0. This might happen if you try to pass both a part1 and part3 code, for example.
fix
Initialize `Lang` with only one positional argument (e.g., `Lang('eng')`) or by explicitly using a keyword argument for the specific part you're interested in (e.g., `Lang(part1='en')`).
TypeError: Lang() got an unexpected keyword argument 'name'
You are passing a generic keyword argument like 'name' to the `Lang` constructor, which is not supported since version 2.4.0. The constructor expects specific 'partX' keyword arguments or a single positional argument.
fix
To look up by name, pass the name as a positional argument (e.g., `Lang('English')`). If you need to specify an ISO part, use `part1`, `part2b`, `part2t`, or `part3` as keyword arguments.
ValueError: 'bh' is not a valid ISO 639 identifier or name.
Attempting to create a `Lang` object for the `bh` (Bihari Languages) identifier, which has been deprecated by ISO and removed from the library's dataset.
fix
Use specific ISO 639-3 codes for individual Bihari languages (e.g., `bho` for Bhojpuri) instead of the deprecated collective `bh` identifier.
Upgrade
Version history
2.6.3latest on PyPI · released Jul 23, 2025
Audit
Dependencies

No dependency data recorded yet.

Agent activity
10 hits · last 30 days
node
8
Resources
iso639-lang — pip install iso639-lang · libregistry