{"id":24441,"library":"pytextrank","title":"PyTextRank","description":"Python implementation of TextRank as a spaCy pipeline extension for graph-based natural language work including phrase extraction, keyword extraction, and knowledge graph extraction. Current version 3.3.0, requires Python >=3.7, follows spaCy's extension pattern. Development is active but releases are infrequent.","status":"active","version":"3.3.0","language":"python","source_language":"en","source_url":"https://github.com/DerwenAI/pytextrank","tags":["nlp","textrank","keyword extraction","phrase extraction","knowledge graph","spacy"],"install":[{"cmd":"pip install pytextrank","lang":"bash","label":"PyPI"}],"dependencies":[{"reason":"Core dependency as a pipeline component; must match spaCy version compatibility","package":"spacy","optional":false},{"reason":"Used for graph algorithms; may be optional in future","package":"networkx","optional":true}],"imports":[{"note":"PyTextRank is a pipeline component, not directly instantiated as a standalone object. Use nlp.add_pipe('pytextrank').","wrong":"import pytextrank\nnlp = pytextrank.PyTextRank()","symbol":"PyTextRank","correct":"from spacy.lang.en import English\nimport spacy\nnlp = spacy.load('en_core_web_sm')\nnlp.add_pipe('pytextrank')\nfrom pytextrank import PyTextRank"}],"quickstart":{"code":"import spacy\nimport pytextrank\n\nnlp = spacy.load('en_core_web_sm')\nnlp.add_pipe('pytextrank')\n\ntext = \"Natural language processing enables computers to understand human language. It is used in chatbots and translation.\"\ndoc = nlp(text)\n\nfor phrase in doc._.phrases:\n    print(phrase.text, phrase.rank, phrase.count)","lang":"python","description":"Loads spaCy model, adds PyTextRank pipeline, processes text, and prints extracted keyphrases with rank and count."},"warnings":[{"fix":"Upgrade spaCy: pip install -U spacy","message":"PyTextRank 3.x requires spaCy 3.x. It will not work with spaCy 2.x. If you have spaCy 2.x, install an older PyTextRank version (<=2.x) or upgrade spaCy.","severity":"breaking","affected_versions":"pytextrank>=3.0.0, <3.0.0 with spacy<3.0.0"},{"fix":"Use doc._.phrases instead of doc._.textrank.","message":"Accessing keyphrases via doc._.phrases has replaced the older method doc._.textrank. The old method will be removed in a future version.","severity":"deprecated","affected_versions":"pytextrank>=3.2.0, <3.3.0"},{"fix":"Ensure nlp = spacy.load('en_core_web_sm') before nlp.add_pipe('pytextrank').","message":"The spaCy model must be loaded before adding PyTextRank pipeline. Adding the pipeline before loading the model will fail silently or raise an error.","severity":"gotcha","affected_versions":"all"}],"env_vars":null,"last_verified":"2026-05-01T00:00:00.000Z","next_check":"2026-07-30T00:00:00.000Z","problems":[{"fix":"Run 'pip install pytextrank' in the same environment as spaCy.","cause":"PyTextRank is not installed or installed in a different Python environment.","error":"ModuleNotFoundError: No module named 'pytextrank'"},{"fix":"Add 'import pytextrank' before calling nlp.add_pipe('pytextrank').","cause":"PyTextRank component is not registered; likely because import pytextrank is missing.","error":"KeyError: \"Cannot add pipeline component 'pytextrank' - not found.\""},{"fix":"Verify that nlp.add_pipe('pytextrank') is called after loading the spaCy model and before processing text.","cause":"The spaCy model does not have token extensions set, meaning PyTextRank may not be added correctly or is not active.","error":"AttributeError: 'spacy.tokens.doc.Doc' object has no attribute '_'"}],"ecosystem":"pypi","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}