2016-10-31 18:04:15 +00:00
|
|
|
//- 💫 DOCS > USAGE
|
|
|
|
|
|
|
|
include ../../_includes/_mixins
|
|
|
|
|
|
|
|
p
|
|
|
|
| spaCy is compatible with #[strong 64-bit CPython 2.6+∕3.3+] and
|
|
|
|
| runs on #[strong Unix/Linux], #[strong macOS/OS X] and
|
2017-03-07 17:52:20 +00:00
|
|
|
| #[strong Windows]. The latest spaCy releases are
|
|
|
|
| available over #[+a("https://pypi.python.org/pypi/spacy") pip] (source
|
|
|
|
| packages only) and #[+a("https://anaconda.org/conda-forge/spacy") conda].
|
|
|
|
| Installation requires a working build environment. See notes on
|
2016-10-31 18:04:15 +00:00
|
|
|
| #[a(href="#source-ubuntu") Ubuntu], #[a(href="#source-osx") macOS/OS X]
|
|
|
|
| and #[a(href="#source-windows") Windows] for details.
|
|
|
|
|
2017-05-17 10:03:42 +00:00
|
|
|
+quickstart(QUICKSTART, "Quickstart")
|
|
|
|
+qs({config: 'venv', python: 2}) python -m pip install -U virtualenv
|
|
|
|
+qs({config: 'venv', python: 3}) python -m pip install -U venv
|
|
|
|
+qs({config: 'venv', python: 2}) virtualenv .env
|
|
|
|
+qs({config: 'venv', python: 3}) venv .env
|
|
|
|
+qs({config: 'venv', os: 'mac'}) source .env/bin/activate
|
|
|
|
+qs({config: 'venv', os: 'linux'}) source .env/bin/activate
|
|
|
|
+qs({config: 'venv', os: 'windows'}) .env\Scripts\activate
|
2017-03-16 20:53:44 +00:00
|
|
|
|
2017-05-17 10:03:42 +00:00
|
|
|
+qs({package: 'pip'}) pip install -U spacy
|
|
|
|
|
|
|
|
+qs({package: 'conda'}) conda config --add channels conda-forge
|
|
|
|
+qs({package: 'conda'}) conda install spacy
|
|
|
|
|
|
|
|
+qs({package: 'source'}) git clone https://github.com/explosion/spaCy
|
|
|
|
+qs({package: 'source'}) cd spaCy
|
|
|
|
+qs({package: 'source'}) pip install -r requirements.txt
|
|
|
|
+qs({package: 'source'}) pip install -e .
|
|
|
|
|
|
|
|
+qs({model: 'en'}) python -m spacy download en
|
|
|
|
+qs({model: 'de'}) python -m spacy download de
|
|
|
|
+qs({model: 'fr'}) python -m spacy download fr
|
2017-03-16 20:53:44 +00:00
|
|
|
|
|
|
|
|
2017-03-07 17:52:20 +00:00
|
|
|
+h(2, "pip") pip
|
2017-03-26 12:11:31 +00:00
|
|
|
+badge("pipy")
|
2017-03-07 17:52:20 +00:00
|
|
|
|
|
|
|
p Using pip, spaCy releases are currently only available as source packages.
|
|
|
|
|
2016-10-31 18:04:15 +00:00
|
|
|
+code(false, "bash").
|
|
|
|
pip install -U spacy
|
|
|
|
|
2017-03-07 17:52:20 +00:00
|
|
|
p
|
|
|
|
| When using pip it is generally recommended to install packages in a
|
|
|
|
| #[code virtualenv] to avoid modifying system state:
|
|
|
|
|
|
|
|
+code(false, "bash").
|
|
|
|
virtualenv .env
|
|
|
|
source .env/bin/activate
|
|
|
|
pip install spacy
|
|
|
|
|
|
|
|
+h(2, "conda") conda
|
2017-03-26 12:11:31 +00:00
|
|
|
+badge("conda")
|
2017-03-07 17:52:20 +00:00
|
|
|
|
|
|
|
p
|
|
|
|
| Thanks to our great community, we've finally re-added conda support. You
|
|
|
|
| can now install spaCy via #[code conda-forge]:
|
|
|
|
|
|
|
|
+code(false, "bash").
|
|
|
|
conda config --add channels conda-forge
|
|
|
|
conda install spacy
|
|
|
|
|
|
|
|
p
|
|
|
|
| For the feedstock including the build recipe and configuration, check out
|
|
|
|
| #[+a("https://github.com/conda-forge/spacy-feedstock") this repository].
|
|
|
|
| Improvements and pull requests to the recipe and setup are always appreciated.
|
|
|
|
|
2016-10-31 18:04:15 +00:00
|
|
|
+h(2, "source") Compile from source
|
|
|
|
|
|
|
|
p
|
|
|
|
| The other way to install spaCy is to clone its
|
|
|
|
| #[+a(gh("spaCy")) GitHub repository] and build it from source. That is
|
2017-03-07 17:52:20 +00:00
|
|
|
| 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,
|
2016-10-31 18:04:15 +00:00
|
|
|
| #[+a("https://pip.pypa.io/en/latest/installing/") pip],
|
|
|
|
| #[+a("https://virtualenv.pypa.io/") virtualenv] and
|
|
|
|
| #[+a("https://git-scm.com") git] installed. The compiler part is the
|
|
|
|
| trickiest. How to do that depends on your system. See notes on
|
|
|
|
| #[a(href="#source-ubuntu") Ubuntu], #[a(href="#source-osx") OS X] and
|
|
|
|
| #[a(href="#source-windows") Windows] for details.
|
|
|
|
|
2017-03-07 17:52:20 +00:00
|
|
|
+code(false, "bash").
|
|
|
|
# make sure you are using recent pip/virtualenv versions
|
|
|
|
python -m pip install -U pip virtualenv
|
|
|
|
git clone #{gh("spaCy")}
|
|
|
|
cd spaCy
|
|
|
|
|
|
|
|
virtualenv .env
|
|
|
|
source .env/bin/activate
|
|
|
|
pip install -r requirements.txt
|
|
|
|
pip install -e .
|
|
|
|
|
|
|
|
p
|
|
|
|
| Compared to regular install via pip, #[+a(gh("spaCy", "requirements.txt")) requirements.txt]
|
|
|
|
| additionally installs developer dependencies such as Cython.
|
|
|
|
|
|
|
|
p
|
|
|
|
| Instead of the above verbose commands, you can also use the following
|
|
|
|
| #[+a("http://www.fabfile.org/") Fabric] commands:
|
|
|
|
|
|
|
|
+table(["Command", "Description"])
|
|
|
|
+row
|
|
|
|
+cell #[code fab env]
|
|
|
|
+cell Create #[code virtualenv] and delete previous one, if it exists.
|
|
|
|
|
|
|
|
+row
|
|
|
|
+cell #[code fab make]
|
|
|
|
+cell Compile the source.
|
|
|
|
|
|
|
|
+row
|
|
|
|
+cell #[code fab clean]
|
2017-03-08 10:36:00 +00:00
|
|
|
+cell Remove compiled objects, including the generated C++.
|
2017-03-07 17:52:20 +00:00
|
|
|
|
|
|
|
+row
|
|
|
|
+cell #[code fab test]
|
|
|
|
+cell Run basic tests, aborting after first failure.
|
|
|
|
|
|
|
|
p
|
|
|
|
| All commands assume that your #[code virtualenv] is located in a
|
|
|
|
| directory #[code .env]. If you're using a different directory, you can
|
2017-03-08 10:36:00 +00:00
|
|
|
| change it via the environment variable #[code VENV_DIR], for example:
|
2017-03-07 17:52:20 +00:00
|
|
|
|
|
|
|
+code(false, "bash").
|
|
|
|
VENV_DIR=".custom-env" fab clean make
|
|
|
|
|
2016-10-31 18:04:15 +00:00
|
|
|
+h(3, "source-ubuntu") Ubuntu
|
|
|
|
|
|
|
|
p Install system-level dependencies via #[code apt-get]:
|
|
|
|
|
|
|
|
+code(false, "bash").
|
|
|
|
sudo apt-get install build-essential python-dev git
|
|
|
|
|
|
|
|
+h(3, "source-osx") macOS / OS X
|
|
|
|
|
|
|
|
p
|
|
|
|
| Install a recent version of #[+a("https://developer.apple.com/xcode/") XCode],
|
|
|
|
| including the so-called "Command Line Tools". macOS and OS X ship with
|
2017-03-07 17:52:20 +00:00
|
|
|
| Python and git preinstalled. To compile spaCy with multi-threading support
|
|
|
|
| on macOS / OS X, #[+a("https://github.com/explosion/spaCy/issues/267") see here].
|
2016-11-06 12:46:11 +00:00
|
|
|
|
2016-10-31 18:04:15 +00:00
|
|
|
+h(3, "source-windows") Windows
|
|
|
|
|
|
|
|
p
|
|
|
|
| Install a version of
|
|
|
|
| #[+a("https://www.visualstudio.com/vs/visual-studio-express/") Visual Studio Express]
|
|
|
|
| that matches the version that was used to compile your Python
|
|
|
|
| interpreter. For official distributions these are:
|
|
|
|
|
|
|
|
+table([ "Distribution", "Version"])
|
|
|
|
+row
|
|
|
|
+cell Python 2.7
|
|
|
|
+cell Visual Studio 2008
|
|
|
|
|
|
|
|
+row
|
|
|
|
+cell Python 3.4
|
|
|
|
+cell Visual Studio 2010
|
|
|
|
|
|
|
|
+row
|
2017-03-29 08:35:20 +00:00
|
|
|
+cell Python 3.5+
|
2016-10-31 18:04:15 +00:00
|
|
|
+cell Visual Studio 2015
|
|
|
|
|
|
|
|
+h(2, "tests") Run tests
|
|
|
|
|
|
|
|
p
|
2017-03-07 17:52:20 +00:00
|
|
|
| spaCy comes with an #[+a(gh("spacy", "spacy/tests")) extensive test suite].
|
|
|
|
| First, find out where spaCy is installed:
|
2016-10-31 18:04:15 +00:00
|
|
|
|
|
|
|
+code(false, "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(false, "bash").
|
|
|
|
# make sure you are using recent pytest version
|
|
|
|
python -m pip install -U pytest
|
|
|
|
|
2017-03-18 14:24:20 +00:00
|
|
|
python -m pytest <spacy-directory> --vectors --models --slow
|