Install & Compatibility
Where this runs
tested against v3.3.0 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
py 3.9
✕ build_error
✕ build_error
628MB installed
● package 628MB
Code
Verified usage
Verified import paths — ran on the pinned version, not inferred.
PyTextRank
✓ import pytextrank
✗ from pytextrank import PyTextRank
Loads spaCy model, adds PyTextRank pipeline, processes text, and prints extracted keyphrases with rank and count.
import spacy
import pytextrank
nlp = spacy.load('en_core_web_sm')
nlp.add_pipe('pytextrank')
text = "Natural language processing enables computers to understand human language. It is used in chatbots and translation."
doc = nlp(text)
for phrase in doc._.phrases:
print(phrase.text, phrase.rank, phrase.count)
Debug
Known issues
breakingPyTextRank 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.fixUpgrade spaCy: pip install -U spacy
affects: pytextrank>=3.0.0, <3.0.0 with spacy<3.0.0
deprecatedAccessing keyphrases via doc._.phrases has replaced the older method doc._.textrank. The old method will be removed in a future version.fixUse doc._.phrases instead of doc._.textrank.
affects: pytextrank>=3.2.0, <3.3.0
gotchaThe spaCy model must be loaded before adding PyTextRank pipeline. Adding the pipeline before loading the model will fail silently or raise an error.fixEnsure nlp = spacy.load('en_core_web_sm') before nlp.add_pipe('pytextrank'). affects: all
Upgrade
Version history
3.3.0latest on PyPI · released Feb 21, 2024
Audit
Dependencies
spacyrequiredCore dependency as a pipeline component; must match spaCy version compatibility
networkxoptionalUsed for graph algorithms; may be optional in future