{"id":4781,"library":"stanza","title":"Stanza","description":"Stanza, by the Stanford NLP Group, is a Python NLP library supporting over 70 human languages. It offers a fully neural pipeline for various text analysis tasks, including tokenization, multi-word token expansion, lemmatization, part-of-speech and morphological feature tagging, dependency parsing, and named entity recognition. Stanza also provides a stable Python interface to the Java Stanford CoreNLP Toolkit. Actively maintained, it receives regular updates, with the current version being 1.11.1.","status":"active","version":"1.11.1","language":"en","source_language":"en","source_url":"https://github.com/stanfordnlp/stanza","tags":["NLP","natural language processing","multilingual","deep learning","Stanford NLP","PyTorch"],"install":[{"cmd":"pip install stanza","lang":"bash","label":"Install latest version"}],"dependencies":[{"reason":"Required for Stanza's neural network models; often recommended to install separately before Stanza to avoid dependency conflicts or build issues.","package":"pytorch","optional":false},{"reason":"Optional for advanced features like improved accuracy with fine-tuned transformer models, enabled via 'pip install stanza[transformers]'.","package":"transformers","optional":true},{"reason":"Optional, integrated for smaller models and used with transformers, enabled via 'pip install stanza[transformers]'.","package":"peft","optional":true}],"imports":[{"symbol":"stanza","correct":"import stanza"}],"quickstart":{"code":"import stanza\n\n# Download an English model (only needs to be run once)\n# Stanza will auto-download if models are not found, but explicit download is good practice.\nstanza.download('en')\n\n# Initialize the English neural pipeline\nnlp = stanza.Pipeline('en')\n\n# Process some text\ntext = \"Barack Obama was born in Hawaii. He was the 44th President of the United States.\"\ndoc = nlp(text)\n\n# Access annotations\nprint(f\"Processing: '{text}'\")\nfor i, sent in enumerate(doc.sentences):\n    print(f\"\\nSentence {i+1}:\")\n    for word in sent.words:\n        print(f\"  {word.text}\\tUPOS: {word.upos}\\tLemma: {word.lemma}\\tDepRel: {word.deprel}\\tHead: {doc.sentences[0].words[word.head-1].text if word.head > 0 else 'ROOT'}\")\n\nprint(\"\\nNamed Entities:\")\nfor ent in doc.entities:\n    print(f\"  {ent.text}\\tType: {ent.type}\")","lang":"python","description":"This quickstart downloads the default English language model, initializes a Stanza pipeline, processes a sample text, and then prints out token-level annotations (UPOS, lemma, dependency relation) and named entities."},"warnings":[{"fix":"Update your code to check the new default location (e.g., `platformdirs.user_cache_dir('stanza')`) or explicitly specify the model directory using the `dir` parameter in `stanza.download()` and `stanza.Pipeline()`, or by setting the `STANZA_RESOURCES_DIR` environment variable.","message":"As of v1.11.1, Stanza's default model download location has changed from `~/stanza_resources` to system-specific cache directories via `platformdirs`. This may affect users who relied on the old default path or custom scripts expecting models in `~/stanza_resources`.","severity":"breaking","affected_versions":">=1.11.1"},{"fix":"Ensure PyTorch is installed and compatible with your system and Python version *before* installing Stanza. Refer to the official PyTorch installation instructions for your environment.","message":"Stanza's neural models require PyTorch. Users often encounter `ERROR: Could not find a version that satisfies the requirement torch` during `pip install stanza` if PyTorch is not pre-installed or if there are compatibility issues. Installing PyTorch separately first, especially via a system package manager (e.g., `conda install pytorch ...`), is frequently recommended for a smoother installation.","severity":"gotcha","affected_versions":"All versions"},{"fix":"Collect multiple texts into a list and pass the list to the `nlp()` pipeline for annotation to improve performance.","message":"Processing individual documents or sentences one by one in a loop can be significantly slower than processing them in batches. Stanza is optimized for batch processing.","severity":"gotcha","affected_versions":"All versions"},{"fix":"For new projects, always use `stanza`. If working with legacy code, be aware that `pip install stanfordnlp` would be required for older versions.","message":"Prior to version 1.0.0, the library was named `stanfordnlp`. If you are looking for very old documentation or examples, you might encounter references to this legacy package name.","severity":"deprecated","affected_versions":"<1.0.0"},{"fix":"Ensure your Python environment is running version 3.9 or newer. Upgrade Python if necessary.","message":"Stanza has a strict Python version requirement of >=3.9. Using older Python versions can lead to various runtime errors, including `OSError: [Errno 22] Invalid argument` during model loading on macOS with Python <=3.7.1.","severity":"gotcha","affected_versions":"All versions (if Python < 3.9)"}],"env_vars":null,"last_verified":"2026-04-12T00:00:00.000Z","next_check":"2026-07-11T00:00:00.000Z"}