{"id":14827,"library":"pycountry-convert","title":"pycountry-convert: Country and Continent Code Conversion","description":"pycountry-convert is a Python library that extends `pycountry` by providing conversion functions between ISO country names, various country codes (Alpha-2, Alpha-3), and continent names. It facilitates mapping between these geographical identifiers. The current version is 0.7.2, released in 2018, indicating an infrequent release cadence.","status":"maintenance","version":"0.7.2","language":"en","source_language":"en","source_url":"https://github.com/TuneLab/pycountry-convert","tags":["country","continent","ISO codes","geography","conversion"],"install":[{"cmd":"pip install pycountry-convert","lang":"bash","label":"Install via pip"}],"dependencies":[{"reason":"Core dependency for accessing ISO country, subdivision, language, currency, and script definitions.","package":"pycountry","optional":false},{"reason":"Used for pretty printing, likely for debugging or enhanced output.","package":"pprintpp","optional":true}],"imports":[{"symbol":"pycountry_convert","correct":"import pycountry_convert as pc"}],"quickstart":{"code":"import pycountry_convert as pc\n\n# Convert country name to Alpha-2 code\ncountry_name = 'Germany'\ntry:\n    country_alpha2 = pc.country_name_to_country_alpha2(country_name, cn_name_format='default')\n    print(f\"Alpha-2 code for {country_name}: {country_alpha2}\")\n\n    # Convert Alpha-2 code to continent code\n    continent_code = pc.country_alpha2_to_continent_code(country_alpha2)\n    print(f\"Continent code for {country_alpha2}: {continent_code}\")\n\n    # Convert continent code to continent name\n    continent_name = pc.convert_continent_code_to_continent_name(continent_code)\n    print(f\"Continent name for {continent_code}: {continent_name}\")\n\nexcept KeyError:\n    print(f\"Could not find data for country: {country_name}\")\n","lang":"python","description":"This example demonstrates how to convert a country name to its ISO Alpha-2 code, then to its continent code, and finally to the continent name, chaining the necessary functions. Direct conversion from country name to continent name is not available, requiring these intermediate steps."},"warnings":[{"fix":"Chain the conversion functions: `country_name_to_country_alpha2()` -> `country_alpha2_to_continent_code()` -> `convert_continent_code_to_continent_name()`.","message":"Direct conversion from country name to continent name is not supported. Users must first convert the country name to an ISO Alpha-2 code, then convert the Alpha-2 code to a continent code, and finally convert the continent code to its name.","severity":"gotcha","affected_versions":"All versions (0.x.x)"},{"fix":"Be aware of potential data staleness. For highly current data, consider verifying results against other sources or implementing manual updates if specific country/continent mappings are critical.","message":"The `pycountry-convert` library has not been updated since version 0.7.2 in February 2018. This means its internal data for countries and continents may be outdated and might not reflect recent geopolitical changes or updates to ISO standards, even if its dependency `pycountry` (which has seen more recent updates) is installed separately.","severity":"gotcha","affected_versions":"0.7.2 and potentially earlier"},{"fix":"For performance-critical applications, consider implementing caching (e.g., using `functools.lru_cache` on a wrapper function) or pre-processing and mapping unique country names/codes once.","message":"For large datasets, repeatedly calling conversion functions can be slow due to re-computation. The library itself does not inherently cache results between calls.","severity":"gotcha","affected_versions":"All versions (0.x.x)"}],"env_vars":null,"last_verified":"2026-04-14T00:00:00.000Z","next_check":"2026-07-13T00:00:00.000Z","problems":[],"ecosystem":"pypi"}