{"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":"python","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,"search_vec":"'1.11.1':75 '70':15 'activ':64 'also':52 'analysi':27 'corenlp':62 'current':72 'deep':81 'depend':45 'entiti':49 'expans':35 'featur':43 'fulli':21 'group':7 'human':16 'includ':29 'interfac':57 'java':60 'languag':17,78 'learn':82 'lemmat':36 'librari':12 'maintain':65 'morpholog':42 'multi':32 'multi-word':31 'multilingu':80 'name':48 'natur':77 'neural':22 'nlp':6,11,76,84 'offer':19 'pars':46 'part':38 'part-of-speech':37 'pipelin':23 'process':79 'provid':53 'python':10,56 'pytorch':85 'receiv':67 'recognit':50 'regular':68 'speech':40 'stabl':55 'stanford':5,61,83 'stanza':1,2,51 'support':13 'tag':44 'task':28 'text':26 'token':30,34 'toolkit':63 'updat':69 'various':25 'version':73 'word':33","created_at":"2026-04-12T14:07:20.208761+00:00","updated_at":"2026-04-16T22:20:53.837818+00:00","problems":[{"fix":"pip install stanza","cause":"The 'stanza' library has not been installed in the current Python environment.","error":"ModuleNotFoundError: No module named 'stanza'"},{"fix":"stanza.download('en')","cause":"The necessary language models for the specified language (e.g., 'en') have not been downloaded or cannot be found by Stanza.","error":"stanza.pipeline.core.StanzaFileNotFoundError: Cannot find model for lang=en"},{"fix":"Ensure processor names are valid, choosing from options like 'tokenize', 'mwt', 'pos', 'lemma', 'depparse', 'ner', 'sentiment', etc.","cause":"The 'processors' argument in `stanza.Pipeline` was provided with an invalid or unrecognized processor name.","error":"ValueError: Invalid argument to Stanza. The 'processors' parameter has unexpected value"},{"fix":"Add the necessary processor to the `processors` list when creating the `stanza.Pipeline`, for example: `stanza.Pipeline(processors='tokenize,pos,lemma')`.","cause":"The requested attribute (e.g., 'lemma') does not exist on the `Word` object because the corresponding processor (e.g., 'lemmatize') was not included in the `stanza.Pipeline` initialization.","error":"AttributeError: 'Word' object has no attribute 'lemma'"},{"fix":"Start the Stanford CoreNLP server in a separate process, or ensure the `host` and `port` parameters in `stanza.Pipeline` match the server's address and port.","cause":"Stanza is configured to connect to a Stanford CoreNLP server, but the server is either not running or is inaccessible at the specified host and port.","error":"RuntimeError: CoreNLP server is not running at http://127.0.0.1:9000"}],"ecosystem":"pypi","meta_description":null,"install_score":null,"quickstart_score":null,"quickstart_tag":null,"pypi_latest":"1.14.0","cli_name":"stanza","cli_version":"","type":"library","homepage":"https://stanfordnlp.github.io/stanza/","github":"https://github.com/stanfordnlp/stanza","docs":null,"changelog":null,"pypi":"https://pypi.org/project/stanza/","npm":null,"openapi_spec":null,"status_page":null,"smithery":null,"categories":["ai-ml"],"base_url":null,"auth_type":null,"provenance":{"verified_status":"passing","verified_at":"2026-06-28","last_verified":"2026-08-30","next_check":"2026-07-28","install_tag":null}}