{"id":9227,"library":"pymorphy2","title":"PyMorphy2","description":"PyMorphy2 (version 0.9.1) is a morphological analyzer and inflection engine for the Russian and Ukrainian languages. It provides functionalities for POS tagging, word inflection, and normalization using OpenCorpora.org dictionaries and heuristic algorithms for unknown words. The project's release cadence is infrequent, with the last significant update in September 2020.","status":"abandoned","version":"0.9.1","language":"en","source_language":"en","source_url":"https://github.com/kmike/pymorphy2/","tags":["NLP","morphology","Russian","Ukrainian","POS tagging","inflection","language processing"],"install":[{"cmd":"pip install pymorphy2","lang":"bash","label":"Install PyMorphy2"},{"cmd":"pip install pymorphy2 pymorphy2-dicts","lang":"bash","label":"Install PyMorphy2 with dictionaries"}],"dependencies":[{"reason":"Required for morphological analysis; contains pre-compiled OpenCorpora.org dictionary data.","package":"pymorphy2-dicts","optional":false},{"reason":"Underlying dependency for efficient dictionary lookups.","package":"DAWG-Python","optional":false}],"imports":[{"symbol":"MorphAnalyzer","correct":"from pymorphy2 import MorphAnalyzer"}],"quickstart":{"code":"import pymorphy2\n\nmorph = pymorphy2.MorphAnalyzer()\nword = 'стекло'\n\n# Analyze a word\nparsed_word = morph.parse(word)[0]\nprint(f\"Original word: {word}\")\nprint(f\"Normal form: {parsed_word.normal_form}\")\nprint(f\"Part of speech: {parsed_word.tag.POS}\")\nprint(f\"All tags: {parsed_word.tag}\")\n\n# Inflect a word\ninflected = parsed_word.inflect({'gent'})\nif inflected: # Check if inflection was successful\n    print(f\"Inflected to genitive: {inflected.word}\")\nelse:\n    print(f\"Could not inflect '{word}' to genitive.\")","lang":"python","description":"Initializes the MorphAnalyzer and demonstrates basic usage: parsing a word to find its normal form and part of speech, and inflecting it to a different grammatical form. The `pymorphy2-dicts` package must be installed for dictionaries to be found."},"warnings":[{"fix":"Ensure your project uses Python 3.5 or newer. For Python 3.11/3.12+, be aware of potential compatibility issues or consider community forks.","message":"PyMorphy2 versions 0.9.x dropped support for Python 2.6 and Python 3.2-3.4. While Python 2.7 is still technically supported by 0.9.1, explicit support for Python 2.x is planned to be removed in a future v1.0, and Python 3.5+ is recommended. Newer Python versions (3.11, 3.12) report issues.","severity":"breaking","affected_versions":"<=0.9"},{"fix":"For active development, consider monitoring or contributing to community forks (e.g., 'pymorphy2-fork' on GitHub) or exploring alternative NLP libraries if long-term maintenance is critical.","message":"The original `pymorphy2` project is largely unmaintained, with GitHub issues indicating it might be abandoned. This means limited support for newer Python versions, bug fixes, or new features. A community-driven fork (`pymorphy2-fork`) exists to continue development.","severity":"gotcha","affected_versions":"0.9.1"},{"fix":"Always check against valid grammeme sets or use the provided API correctly. For example, to check for plural, use `tag.number == 'plur'` or `('plur' in tag)`.","message":"Directly comparing `tag.POS` or other `tag` attributes with arbitrary string values (e.g., `tag.POS == 'plur'`) can lead to `ValueError` if the string is not a valid grammeme for that attribute. Use `tag.grammemes` for comprehensive checks or refer to documentation for valid grammeme values.","severity":"gotcha","affected_versions":"All"},{"fix":"Ensure `pymorphy2` (and `pymorphy2-dicts`) is installed before the main Python process starts, or restart the kernel/runtime after installation. Upgrade to `0.9.1` or later.","message":"When installing `pymorphy2` in environments like Jupyter Notebook or Google Colab after the process has started (e.g., `!pip install`), dictionary discovery might fail. Version 0.9.1 fixed this, but older versions or unusual setups might still encounter it.","severity":"gotcha","affected_versions":"<0.9.1"}],"env_vars":null,"last_verified":"2026-04-16T00:00:00.000Z","next_check":"2026-07-15T00:00:00.000Z","problems":[{"fix":"Install the dictionary package: `pip install pymorphy2-dicts`.","cause":"The `pymorphy2-dicts` package, which contains the necessary morphological dictionaries, is not installed or cannot be found by `pymorphy2`.","error":"DictionaryNotFound: Dictionary for language 'ru' not found. Download it using 'python -m pymorphy2.downloader'."},{"fix":"Verify installation with `pip show pymorphy2`. If installed, check for conflicting local files or environment path issues. A common mistake is `import pymorphy2.MorphAnalyzer` instead of `from pymorphy2 import MorphAnalyzer`.","cause":"This error typically occurs if `pymorphy2` is not properly installed or if there's a naming conflict in your environment (e.g., a local file named `pymorphy2.py`).","error":"ImportError: cannot import name 'MorphAnalyzer' from 'pymorphy2'"},{"fix":"Try `pip install pymorphy2` without the `[fast]` extra. Ensure all dependencies are up-to-date. If issues persist, consider using a Python version that is known to be stable with `pymorphy2` (e.g., Python 3.8/3.9) or consult the project's GitHub issues for workarounds.","cause":"Reported in some GitHub issues, particularly with Python 3.7+ and specific installation methods (e.g., `pymorphy2[fast]`). This often indicates low-level C extension issues, possibly related to `DAWG-Python` dependencies.","error":"Segmentation fault (core dumped)"}]}