{"id":6608,"library":"doublemetaphone","title":"Double Metaphone for Python","description":"The `doublemetaphone` library provides a Python wrapper for the C++ implementation of the Double Metaphone phonetic algorithm. This algorithm generates approximate phonetic representations (codes) for words, useful for matching names or words with similar pronunciations despite different spellings. The current version is 1.2. Releases appear to be infrequent, with significant gaps between updates.","status":"active","version":"1.2","language":"python","source_language":"en","source_url":"https://github.com/dedupeio/doublemetaphone","tags":["phonetics","string-matching","nlp","fuzzy-matching","metaphone"],"install":[{"cmd":"pip install doublemetaphone","lang":"bash","label":"Install with pip"}],"dependencies":[{"reason":"This is a Python wrapper for a C++ library. While pre-built wheels are often available, a C++ compiler (like GCC or MSVC) is required if installing from source or for platforms without pre-built wheels.","package":"C++ compiler","optional":true}],"imports":[{"note":"The primary function is directly exposed from the top-level package, not nested further.","wrong":"import doublemetaphone; doublemetaphone.doublemetaphone.doublemetaphone('word')","symbol":"doublemetaphone","correct":"from doublemetaphone import doublemetaphone"}],"quickstart":{"code":"from doublemetaphone import doublemetaphone\n\nword1 = \"Smith\"\nword2 = \"Schmidt\"\n\nprimary1, secondary1 = doublemetaphone(word1)\nprimary2, secondary2 = doublemetaphone(word2)\n\nprint(f\"'{word1}': Primary='{primary1}', Secondary='{secondary1}'\")\nprint(f\"'{word2}': Primary='{primary2}', Secondary='{secondary2}'\")\n\n# Double Metaphone often returns two codes to account for phonetic ambiguities.\n# For example, 'Smith' and 'Schmidt' share a secondary code.\nif primary1 == primary2 or secondary1 == secondary2 or primary1 == secondary2 or primary2 == secondary1:\n    print(f\"'{word1}' and '{word2}' are phonetically similar.\")","lang":"python","description":"Generate Double Metaphone codes for a word and compare them. The function returns a tuple of (primary_code, secondary_code)."},"warnings":[{"fix":"Always unpack the return value into two variables: `primary, secondary = doublemetaphone('word')`.","message":"The `doublemetaphone` function returns a tuple of two strings (primary and secondary codes), not a single string. Ensure your code handles both return values, even if one is an empty string.","severity":"gotcha","affected_versions":"All versions"},{"fix":"Ensure all input strings are Python 3 `str` objects (Unicode). Explicitly decode byte strings if necessary (e.g., `my_bytes.decode('utf-8')`).","message":"Older versions (primarily Python 2) might have raised `TypeError` if non-unicode strings were passed. Python 3 strings are Unicode by default, but be mindful of encoding if dealing with byte strings or legacy data.","severity":"breaking","affected_versions":"<1.1 (Python 2), potential edge cases in 1.x with bytes"},{"fix":"Verify the `pip install` command and `import` statement match the `doublemetaphone` package specifically. Check the PyPI project description to confirm it's the C++ wrapper.","message":"There are multiple Python packages implementing or wrapping Metaphone/Double Metaphone algorithms (e.g., `metaphone`, `phonetics`, `doublemetaphone`). Ensure you install and import the correct package for the C++ wrapper implementation (`doublemetaphone`).","severity":"gotcha","affected_versions":"All versions"},{"fix":"If `pip install` fails with compilation errors, install a C++ compiler (e.g., build-essential on Linux, Xcode Command Line Tools on macOS, Visual C++ Build Tools on Windows) or consider using a pre-packaged environment (e.g., Docker).","message":"Installation might require a C++ compiler if a pre-built wheel is not available for your specific Python version and operating system. This is common for Python wrappers around C/C++ libraries.","severity":"gotcha","affected_versions":"All versions, on environments without compatible wheels"}],"env_vars":null,"search_vec":"'1.2':47 'algorithm':21,23 'appear':49 'approxim':25 'c':14 'code':28 'current':44 'despit':40 'differ':41 'doubl':1,18 'doublemetaphon':6 'fuzzi':64 'fuzzy-match':63 'gap':55 'generat':24 'implement':15 'infrequ':52 'librari':7 'match':33,61,65 'metaphon':2,19,66 'name':34 'nlp':62 'phonet':20,26,58 'pronunci':39 'provid':8 'python':4,10 'releas':48 'represent':27 'signific':54 'similar':38 'spell':42 'string':60 'string-match':59 'updat':57 'use':31 'version':45 'word':30,36 'wrapper':11","created_at":"2026-04-15T18:35:13.103222+00:00","updated_at":"2026-04-16T14:41:20.380800+00:00","problems":[{"fix":"On Windows, install 'Build Tools for Visual Studio' (specifically, the C++ build tools). On Linux, install `build-essential` (e.g., `sudo apt-get install build-essential`). For Python versions where setuptools might have issues, ensure setuptools is updated: `pip install --upgrade setuptools pip`.","cause":"This error indicates that `pip` was unable to compile the C++ extension required by the `doublemetaphone` library, often due to a missing C++ compiler or development tools on your system.","error":"ERROR: Failed building wheel for doublemetaphone"},{"fix":"Ensure that the Microsoft Visual C++ Redistributable for your Python version (e.g., 2015-2022) is installed. Also, verify that the `doublemetaphone` package was installed correctly in the active Python environment.","cause":"This specific `ImportError`, commonly seen on Windows, means that a dynamically linked library (DLL) that `doublemetaphone` depends on could not be located by the Python interpreter, often related to the Visual C++ Redistributable.","error":"ImportError: DLL load failed while importing doublemetaphone: The specified module could not be found."},{"fix":"Ensure you have installed the package using `pip install doublemetaphone` in the correct Python environment. If you have multiple Python installations, activate the intended environment before installing or specify the Python executable (e.g., `python -m pip install doublemetaphone`).","cause":"This error means Python cannot find the `doublemetaphone` package, usually because it was not installed, was installed in a different Python environment, or the installation failed without a clear error message.","error":"ModuleNotFoundError: No module named 'doublemetaphone'"}],"ecosystem":"pypi","meta_description":"doublemetaphone · phonetic algorithm · pip install doublemetaphone · from doublemetaphone import doublemetaphone · fails on Windows: needs Visual C++ build tools","install_score":null,"quickstart_score":null,"quickstart_tag":null,"pypi_latest":"1.2","cli_name":"","cli_version":null,"type":"library","homepage":null,"github":null,"docs":null,"changelog":null,"pypi":"https://pypi.org/project/doublemetaphone/","npm":null,"openapi_spec":null,"status_page":null,"smithery":null,"categories":["serialization"],"base_url":null,"auth_type":null,"provenance":{"verified_status":"passing","verified_at":"2026-06-28","last_verified":"2026-06-28","next_check":"2026-07-28","install_tag":null}}