2016-10-03 21:19:13 +03:00
//- ----------------------------------
//- 💫 QUICKSTART > GETTING STARTED
//- ----------------------------------
2016-03-31 17:24:48 +03:00
2016-10-03 21:19:13 +03:00
+section("getting-started")
+h(2, "getting-started")
| Getting started
2016-03-31 17:24:48 +03:00
2016-10-03 21:19:13 +03:00
+section("install-spacy")
+h(3, "install-spacy")
| Install spaCy
2016-03-31 17:24:48 +03:00
p.
2016-10-03 21:19:13 +03:00
spaCy is compatible with 64-bit CPython 2.6+/3.3+ and runs on Unix/Linux,
OS X and Windows. Source and binary packages are available via
#[+a("https://pypi.python.org/pypi/spacy") pip] and
#[+a("https://anaconda.org/spacy/spacy") conda]. If there are
no binary packages for your platform available please make sure that you have
a working build enviroment set up. See
notes on #[a(href="/docs#install-source-ubuntu") Ubuntu],
#[a(href="/docs#install-source-osx") OS X] and
#[a(href="/docs#install-source-windows") Windows] for details.
+code("bash", "conda").
conda config --add channels spacy # only needed once
conda install spacy
2016-03-31 17:24:48 +03:00
p.
2016-10-03 21:19:13 +03:00
When using pip it is generally recommended to install packages in a
#[+a("https://virtualenv.readthedocs.org/en/latest/") virtualenv]
2016-03-31 17:24:48 +03:00
to avoid modifying system state:
2016-10-03 21:19:13 +03:00
+code("bash", "pip").
# make sure you are using a recent pip/virtualenv version
python -m pip install -U pip virtualenv
2016-03-31 17:24:48 +03:00
2016-10-03 21:19:13 +03:00
virtualenv .env
source .env/bin/activate
2016-03-31 17:24:48 +03:00
2016-10-03 21:19:13 +03:00
pip install spacy
2016-03-31 17:24:48 +03:00
p.
2016-10-03 21:19:13 +03:00
Python packaging is awkward at the best of times, and it's particularly
tricky with C extensions, built via Cython, requiring large data files.
So, please report issues as you encounter them.
2016-03-31 17:24:48 +03:00
2016-10-03 21:19:13 +03:00
+section("install-model")
+h(3, "install-model")
| Install model
2016-03-31 17:24:48 +03:00
p.
2016-10-03 21:19:13 +03:00
After installation you need to download a language model.
Currently only models for English and German, named #[code en] and #[code de], are available. Please get in touch with us if you need support for a particular language.
+code("bash").
sputnik --name spacy --repository-url http://index.spacy.io install en==1.1.0
2016-03-31 17:24:48 +03:00
p.
2016-10-03 21:19:13 +03:00
Then check whether the model was successfully installed:
2016-03-31 17:24:48 +03:00
2016-10-03 21:19:13 +03:00
+code("bash").
python -c "import spacy; spacy.load('en'); print('OK')"
2016-03-31 17:24:48 +03:00
p.
2016-10-03 21:19:13 +03:00
The download command fetches and installs about 500 MB of data which it installs
within the #[code spacy] package directory.
2016-03-31 17:24:48 +03:00
2016-10-03 21:19:13 +03:00
+section("install-upgrade")
+h(3, "install-upgrade")
| Upgrading spaCy
2016-03-31 17:24:48 +03:00
2016-10-03 21:19:13 +03:00
p.
To upgrade spaCy to the latest release:
+code("bash", "conda").
conda update spacy
+code("bash", "pip").
pip install -U spacy
2016-03-31 17:24:48 +03:00
p.
2016-10-03 21:19:13 +03:00
Sometimes new releases require a new language model. Then you will have to upgrade to
a new model, too. You can also force re-downloading and installing a new language model:
2016-03-31 17:24:48 +03:00
2016-10-03 21:19:13 +03:00
+code("bash").
python -m spacy.en.download --force
2016-03-31 17:24:48 +03:00
2016-10-03 21:19:13 +03:00
+section("install-source")
+h(3, "install-source")
2016-03-31 17:24:48 +03:00
| Compile from source
p.
2016-10-03 21:19:13 +03:00
The other way to install spaCy is to clone its
#[a(href="https://github.com/spacy-io/spaCy") GitHub repository] and
build it from source. That is the common way if you want to make changes
to the code base.
2016-03-31 17:24:48 +03:00
2016-10-03 21:19:13 +03:00
p.
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 #[a(href="/docs#install-source-ubuntu") Ubuntu],
#[a(href="/docs#install-source-osx") OS X] and
#[a(href="/docs#install-source-windows") Windows] for details.
+code("bash").
# make sure you are using recent pip/virtualenv versions
python -m pip install -U pip virtualenv
# find git install instructions at https://git-scm.com/downloads
2016-03-31 17:24:48 +03:00
git clone https://github.com/spacy-io/spaCy.git
2016-10-03 21:19:13 +03:00
2016-03-31 17:24:48 +03:00
cd spaCy
virtualenv .env && source .env/bin/activate
pip install -r requirements.txt
pip install -e .
p.
2016-10-03 21:19:13 +03:00
Compared to regular install via #[code pip] and #[code conda]
#[+a("https://github.com/" + SOCIAL.github + "/spaCy/blob/master/requirements.txt") requirements.txt]
additionally installs developer dependencies such as #[code cython].
+h(4, "install-source-ubuntu")
| Ubuntu
p Install system-level dependencies via #[code apt-get]:
+code("bash").
sudo apt-get install build-essential python-dev git
2016-03-31 17:24:48 +03:00
2016-10-03 21:19:13 +03:00
+h(4, "install-source-osx")
| OS X
2016-03-31 17:24:48 +03:00
p.
2016-10-03 21:19:13 +03:00
Install a recent version of XCode, including the so-called "Command Line Tools". OS X
ships with Python and git preinstalled.
+h(4, "install-source-windows")
| Windows
p.
Install a version of Visual Studio Express or higher that matches the version that was
used to compile your Python interpreter. For official distributions
these are VS 2008 (Python 2.7), VS 2010 (Python 3.4) and VS 2015 (Python 3.5).
+section("install-obsolete-python")
+h(3, "install-obsolete-python")
| Workaround for obsolete system Python
p.
If you're stuck using a system with an old version of Python, and you
don't have root access, we've prepared a bootstrap script to help you
compile a local Python install. Run:
+code("bash").
curl https://raw.githubusercontent.com/spacy-io/gist/master/bootstrap_python_env.sh | bash && source .env/bin/activate
+section("run-tests")
+h(3, "run-tests")
| Run tests
p.
spaCy comes with an extensive test suite. First, find out where spaCy is installed:
+code("bash").
python -c "import os; import spacy; print(os.path.dirname(spacy.__file__))"
p.
Then run #[code pytest] on that directory. The flags #[code --vectors],
#[code --slow] and #[code --model] are optional and enable additional tests:
+code("bash").
# make sure you are using recent pytest version
python -m pip install -U pytest
python -m pytest <spacy-directory> --vectors --model --slow