iso-639

raw JSON →
0.4.5 verified Mon Apr 27 auth: no python

Python library for ISO 639 standard, providing mappings between language names, ISO 639-1 (alpha-2), ISO 639-2 (alpha-3), and ISO 639-3 codes. Version 0.4.5 is the latest release (as of 2025).

pip install iso-639
error AttributeError: module 'iso639' has no attribute 'Language'
cause Importing the iso639 module instead of the Language class from the iso639 submodule.
fix
Use 'from iso639 import Language'
error iso639.errors.InvalidLanguageValue: The language value 'xyz' is not valid.
cause Passing an invalid language name or code to the Language constructor.
fix
Ensure the language name/code is valid according to ISO 639. Use try/except with InvalidLanguageValue.
gotcha The library raises InvalidLanguageValue (not ValueError) if the input is not found. Catch the custom exception.
fix from iso639 import InvalidLanguageValue; try: Language('zzz') except InvalidLanguageValue: ...
gotcha Some languages have multiple ISO 639-2 codes (B and T). Use .pt2b (bibliographic) and .pt2t (terminology) attributes.
fix Use lang.pt2b for bibliographic code, lang.pt2t for terminology code.
deprecated The old API with iso639.list_languages() is deprecated; use iteration over Language class.
fix Replace iso639.list_languages() with [l for l in Language]

Instantiate a Language object with a name or code to access properties.

from iso639 import Language

# Search by name (case-insensitive)
lang = Language('English')
print(lang.name)       # 'English'
print(lang.pt1)        # 'en'
print(lang.pt2b)       # 'eng'
print(lang.pt3)        # 'eng'

# Search by ISO 639-1 code
lang2 = Language('fr')
print(lang2.name)      # 'French'

# Iterate all languages
for l in Language:
    print(l.name, l.pt1)
    break