Skip to content

Guide · Open source

How to use spaCy: install, run pipelines and train models

Updated · written with AI from the project's own documentation and checked against our catalogue data

spaCy is an open-source Python library for natural language processing, the work of getting programs to read and understand written text. This guide walks you through installing it, what it can do with a piece of text, and where to go when you want to train your own models. You need basic Python skills to follow along, since spaCy is a code library rather than a no-code tool.

spaCyexplosion/spaCy · ★ 34k · MIT

Quick start

  1. 1Check Python is installed. spaCy needs Python. Confirm you have a working Python environment before installing anything.
  2. 2Install spaCy. Run pip install -U spacy in your terminal to install spaCy from PyPI.
  3. 3Find a pretrained pipeline. Open the Models page on the spaCy site and choose a pipeline for your language and task.
  4. 4Load the pipeline in Python. Import spaCy and load your chosen pipeline by name, following the usage guide for that package.
  5. 5Process your text. Pass a string to the loaded pipeline and inspect the tokens, tags and named entities it returns.
  6. 6Train your own model if needed. If pretrained pipelines do not fit your data, follow the training usage guide to build a custom model.

What spaCy does with text

spaCy can split text into words, tag parts of speech, parse sentence structure, and recognize named entities such as people or places. It ships with pretrained pipelines, so you can start analysing text without training anything yourself.

The README describes spaCy as built for use in real products, with neural network models for tagging, parsing, named entity recognition and text classification.

  • Tokenization: splitting text into words and symbols
  • Part-of-speech tagging and sentence parsing
  • Named entity recognition, such as people and places
  • Text classification with neural network models

Install spaCy with pip

spaCy is installed from PyPI with pip. The only listed prerequisite is Python. Run the install command in your terminal or virtual environment.

The -U flag upgrades spaCy if it is already installed.

pip install -U spacy

Load a pretrained pipeline and analyse text

Pretrained pipelines are downloadable packages that bundle the models spaCy needs to tag and parse text. The README points to the Models section of the spaCy site for the list of available pipelines.

Once a pipeline is loaded, you pass it a string and get back a document whose tokens, tags and entities you can inspect. Check the spaCy usage guides for the exact load and download commands for the pipeline you choose.

Work with 70+ languages

The README says spaCy currently supports tokenization and training for 70+ languages. Support for pretrained pipelines can differ by language, so confirm that your language has the components you need on the Models page before you build on it.

Train or customize your own model

spaCy supports training your own neural network models and includes a production-ready training system, along with model packaging, deployment and workflow management. This is useful when a pretrained pipeline does not match your domain.

Training details live in the spaCy training usage guide and the Project Templates section, which contains end-to-end workflows you can clone, modify and run.

Where to learn more

The official documentation is organised into spaCy 101 for newcomers, Usage Guides, the API Reference, and a GPU Processing guide for CUDA-compatible GPUs. The Universe section lists plugins, extensions, demos and books from the wider ecosystem.

What people use it for

  • Extracting people, organisations and places from news articles or support tickets
  • Adding text analysis features to a Python web application
  • Tagging parts of speech as a preprocessing step for other NLP work
  • Training a custom text classifier for your own labelled data
  • Learning practical NLP with a well-documented library

Frequently asked questions

Is spaCy free to use?

Yes. spaCy is released under the MIT license, which the README links to. The license is listed on the repository, so check the LICENSE file if you need the exact terms for a commercial project.

How do I install spaCy?

Run pip install -U spacy in a terminal with Python available. The README lists PyPI as the source, and Python is the only listed prerequisite.

What are the requirements for spaCy?

The listed prerequisite is Python. spaCy is a Python and Cython library, so you need to be comfortable writing Python code to use it.

Does spaCy support my language?

The README says spaCy supports tokenization and training for 70+ languages. Check the Models page to see which pretrained pipelines exist for your specific language.

How does spaCy compare to NLTK?

Both are Python NLP libraries. The README positions spaCy for production-ready pipelines and neural models; NLTK is listed as a comparable project, so compare them on the tasks you need.

Is spaCy a good choice if I want a no-code tool?

No. spaCy is a code library that requires Python skills. If you need a no-code tool, look for a graphical text analysis product instead.

New agent skills, repos and AI tools — every week

The best new skills and open-source projects, the fastest-growing repos, and one free prompt. Five minutes to read. Unsubscribe anytime.

Our verdict

spaCy suits Python developers and data scientists who need reliable NLP pipelines inside an application or want to train their own text models. If you need no-code tools, a language outside spaCy's coverage, or mainly large chat-style language models, pick a different option such as Hugging Face Transformers for those use cases.

Install options & downloads