Install spaCy

spaCy is compatible with 64-bit CPython 2.6+∕3.3+ and runs on Unix/Linux, macOS/OS X and Windows. The latest spaCy releases are available over pip (source packages only) and conda. Installation requires a working build environment. See notes on Ubuntu, macOS/OS X and Windows for details.

pip{name} version

Using pip, spaCy releases are currently only available as source packages.

pip install -U spacy

When using pip it is generally recommended to install packages in a virtualenv to avoid modifying system state:

virtualenv .env
source .env/bin/activate
pip install spacy

conda{name} version

Thanks to our great community, we've finally re-added conda support. You can now install spaCy via conda-forge:

conda config --add channels conda-forge
conda install spacy

For the feedstock including the build recipe and configuration, check out this repository. Improvements and pull requests to the recipe and setup are always appreciated.

Compile from source

The other way to install spaCy is to clone its GitHub repository and build it from source. That is the common way if you want to make changes to the code base. You'll need to make sure that you have a development enviroment consisting of a Python distribution including header files, a compiler, pip, virtualenv and git installed. The compiler part is the trickiest. How to do that depends on your system. See notes on Ubuntu, OS X and Windows for details.

# make sure you are using recent pip/virtualenv versions
python -m pip install -U pip virtualenv
git clone https://github.com/explosion/spaCy
cd spaCy

virtualenv .env
source .env/bin/activate
pip install -r requirements.txt
pip install -e .

Compared to regular install via pip, requirements.txt additionally installs developer dependencies such as Cython.

Instead of the above verbose commands, you can also use the following Fabric commands:

CommandDescription
fab envCreate virtualenv and delete previous one, if it exists.
fab makeCompile the source.
fab cleanRemove compiled objects, including the generated C++.
fab testRun basic tests, aborting after first failure.

All commands assume that your virtualenv is located in a directory .env. If you're using a different directory, you can change it via the environment variable VENV_DIR, for example:

VENV_DIR=".custom-env" fab clean make

Ubuntu

Install system-level dependencies via apt-get:

sudo apt-get install build-essential python-dev git

macOS / OS X

Install a recent version of XCode, including the so-called "Command Line Tools". macOS and OS X ship with Python and git preinstalled. To compile spaCy with multi-threading support on macOS / OS X, see here.

Windows

Install a version of Visual Studio Express that matches the version that was used to compile your Python interpreter. For official distributions these are:

DistributionVersion
Python 2.7Visual Studio 2008
Python 3.4Visual Studio 2010
Python 3.5+Visual Studio 2015

Run tests

spaCy comes with an extensive test suite. First, find out where spaCy is installed:

python -c "import os; import spacy; print(os.path.dirname(spacy.__file__))"

Then run pytest on that directory. The flags --vectors, --slow and --model are optional and enable additional tests:

# make sure you are using recent pytest version
python -m pip install -U pytest

python -m pytest <spacy-directory> --vectors --models --slow
Read next: Models