PythonとCythonの高度な自然言語処理用「spacy」をインストールする

PythonとCythonの高度な自然言語処理用「spacy」のインストールについて解説しています。

spacy(https://spacy.io/)は、60以上の言語のサポート(日本語も対応)しており、タグ付け、解析、名前付きエンティティの認識、テキスト分類などの最先端の速度モデルとニューラルネットワークモデルを使用したマルチタスク学習、トレーニングシステムと簡単なモデルなどを備えている。

■Python

今回のPythonのバージョンは、「3.6」を使用しています。(Windows10)(pythonランチャーでの確認)

■spacyをインストールする

spacyをインストールを行いますが、今回はpipを経由してインストールを行うので、まずWindowsのコマンドプロンプトを起動します。

pip install spacy[ja]

起動後、上記のコマンドを入力し、Enterキーを押します。

なお、今回は、pythonランチャーを使用しており、Python Version 3.6にインストールを行うために、pipを使う場合にはコマンドでの切り替えを行います。

py -3.6 -m pip install spacy[ja]

切り替えるために、上記のコマンドを入力し、Enterキーを押します。

Defaulting to user installation because normal site-packages is not writeable
Collecting spacy[ja]
Downloading spacy-3.2.1-cp36-cp36m-win_amd64.whl (12.0 MB)
|████████████████████████████████| 12.0 MB 3.3 MB/s
Collecting typer<0.5.0,>=0.3.0
Using cached typer-0.4.0-py3-none-any.whl (27 kB)
Requirement already satisfied: requests<3.0.0,>=2.13.0 in c:\users\user_\appdata\roaming\python\python36\site-packages (from spacy[ja]) (2.26.0)
Requirement already satisfied: tqdm<5.0.0,>=4.38.0 in c:\users\user_\appdata\roaming\python\python36\site-packages (from spacy[ja]) (4.62.3)
Collecting blis<0.8.0,>=0.4.0
Downloading blis-0.7.5-cp36-cp36m-win_amd64.whl (6.5 MB)
|████████████████████████████████| 6.5 MB 6.4 MB/s
Collecting srsly<3.0.0,>=2.4.1
Downloading srsly-2.4.2-cp36-cp36m-win_amd64.whl (450 kB)
|████████████████████████████████| 450 kB 6.4 MB/s
Collecting murmurhash<1.1.0,>=0.28.0
Downloading murmurhash-1.0.6-cp36-cp36m-win_amd64.whl (20 kB)
Collecting spacy-loggers<2.0.0,>=1.0.0
Using cached spacy_loggers-1.0.1-py3-none-any.whl (7.0 kB)
Requirement already satisfied: numpy>=1.15.0 in c:\users\user_\appdata\roaming\python\python36\site-packages (from spacy[ja]) (1.19.5)
Requirement already satisfied: packaging>=20.0 in c:\users\user_\appdata\roaming\python\python36\site-packages (from spacy[ja]) (21.2)
Collecting thinc<8.1.0,>=8.0.12
Downloading thinc-8.0.13-cp36-cp36m-win_amd64.whl (1.0 MB)
|████████████████████████████████| 1.0 MB 3.3 MB/s
Collecting pydantic!=1.8,!=1.8.1,<1.9.0,>=1.7.4
Downloading pydantic-1.8.2-cp36-cp36m-win_amd64.whl (1.9 MB)
|████████████████████████████████| 1.9 MB 2.2 MB/s
Collecting catalogue<2.1.0,>=2.0.6
Using cached catalogue-2.0.6-py3-none-any.whl (17 kB)
Collecting spacy-legacy<3.1.0,>=3.0.8
Using cached spacy_legacy-3.0.8-py2.py3-none-any.whl (14 kB)
Collecting preshed<3.1.0,>=3.0.2
Downloading preshed-3.0.6-cp36-cp36m-win_amd64.whl (109 kB)
|████████████████████████████████| 109 kB 6.4 MB/s
Requirement already satisfied: setuptools in c:\users\user_\appdata\roaming\python\python36\site-packages (from spacy[ja]) (58.5.3)
Collecting jinja2
Downloading Jinja2-3.0.3-py3-none-any.whl (133 kB)
|████████████████████████████████| 133 kB 3.2 MB/s
Requirement already satisfied: typing-extensions<4.0.0.0,>=3.7.4 in c:\users\user_\appdata\roaming\python\python36\site-packages (from spacy[ja]) (3.10.0.2)
Collecting pathy>=0.3.5
Using cached pathy-0.6.1-py3-none-any.whl (42 kB)
Collecting wasabi<1.1.0,>=0.8.1
Downloading wasabi-0.9.0-py3-none-any.whl (25 kB)
Collecting cymem<2.1.0,>=2.0.2
Downloading cymem-2.0.6-cp36-cp36m-win_amd64.whl (35 kB)
Collecting langcodes<4.0.0,>=3.2.0
Downloading langcodes-3.3.0-py3-none-any.whl (181 kB)
|████████████████████████████████| 181 kB 3.3 MB/s
Collecting sudachipy>=0.4.9
Downloading SudachiPy-0.6.2-cp36-cp36m-win_amd64.whl (1.0 MB)
|████████████████████████████████| 1.0 MB 3.3 MB/s
Collecting sudachidict-core>=20200330
Using cached SudachiDict-core-20210802.post1.tar.gz (9.1 kB)
Requirement already satisfied: zipp>=0.5 in c:\users\user_\appdata\roaming\python\python36\site-packages (from catalogue<2.1.0,>=2.0.6->spacy[ja]) (3.6.0)
Requirement already satisfied: pyparsing<3,>=2.0.2 in c:\users\user_\appdata\roaming\python\python36\site-packages (from packaging>=20.0->spacy[ja]) (2.4.7)
Requirement already satisfied: smart-open<6.0.0,>=5.0.0 in c:\users\user_\appdata\roaming\python\python36\site-packages (from pathy>=0.3.5->spacy[ja]) (5.2.1)
Requirement already satisfied: dataclasses<1.0,>=0.6 in c:\users\user_\appdata\roaming\python\python36\site-packages (from pathy>=0.3.5->spacy[ja]) (0.8)
Requirement already satisfied: idna<4,>=2.5 in c:\users\user_\appdata\roaming\python\python36\site-packages (from requests<3.0.0,>=2.13.0->spacy[ja]) (2.8)
Requirement already satisfied: urllib3<1.27,>=1.21.1 in c:\users\user_\appdata\roaming\python\python36\site-packages (from requests<3.0.0,>=2.13.0->spacy[ja]) (1.24.3)
Requirement already satisfied: charset-normalizer~=2.0.0 in c:\users\user_\appdata\roaming\python\python36\site-packages (from requests<3.0.0,>=2.13.0->spacy[ja]) (2.0.7)
Requirement already satisfied: certifi>=2017.4.17 in c:\users\user_\appdata\roaming\python\python36\site-packages (from requests<3.0.0,>=2.13.0->spacy[ja]) (2020.12.5)
Collecting contextvars<3,>=2.4
Downloading contextvars-2.4.tar.gz (9.6 kB)
Collecting immutables>=0.9
Downloading immutables-0.16-cp36-cp36m-win_amd64.whl (59 kB)
|████████████████████████████████| 59 kB 1.7 MB/s
Requirement already satisfied: colorama in c:\users\user_\appdata\roaming\python\python36\site-packages (from tqdm<5.0.0,>=4.38.0->spacy[ja]) (0.4.4)
Requirement already satisfied: click<9.0.0,>=7.1.1 in c:\users\user_\appdata\roaming\python\python36\site-packages (from typer<0.5.0,>=0.3.0->spacy[ja]) (8.0.3)
Requirement already satisfied: importlib-metadata in c:\users\user_\appdata\roaming\python\python36\site-packages (from click<9.0.0,>=7.1.1->typer<0.5.0,>=0.3.0->spacy[ja]) (3.10.1)
Collecting MarkupSafe>=2.0
Downloading MarkupSafe-2.0.1-cp36-cp36m-win_amd64.whl (14 kB)
Building wheels for collected packages: sudachidict-core, contextvars
Building wheel for sudachidict-core (setup.py) ... done
Created wheel for sudachidict-core: filename=SudachiDict_core-20210802.post1-py3-none-any.whl size=71418623 sha256=f42af9455ae019404d541cf04599df901f1b775bade6116d9daa0d9bb7702633
Stored in directory: c:\users\user_\appdata\local\pip\cache\wheels\d8\8c\e0\76fd436dceb059d835dbcef9b24f50424a6fec3cbe9f5f2182
Building wheel for contextvars (setup.py) ... done
Created wheel for contextvars: filename=contextvars-2.4-py3-none-any.whl size=7680 sha256=1ad8a683f1d39b806beee70def20ded00c518cc1e73fe1d125dbe4b0a4d987c4
Stored in directory: c:\users\user_\appdata\local\pip\cache\wheels\41\11\53\911724983aa48deb94792432e14e518447212dd6c5477d49d3
Successfully built sudachidict-core contextvars
Installing collected packages: murmurhash, immutables, cymem, catalogue, wasabi, typer, srsly, pydantic, preshed, MarkupSafe, contextvars, blis, thinc, sudachipy, spacy-loggers, spacy-legacy, pathy, langcodes, jinja2, sudachidict-core, spacy
WARNING: The script sudachipy.exe is installed in 'C:\Users\user_\AppData\Roaming\Python\Python36\Scripts' which is not on PATH.
Consider adding this directory to PATH or, if you prefer to suppress this warning, use --no-warn-script-location.
WARNING: The script pathy.exe is installed in 'C:\Users\user_\AppData\Roaming\Python\Python36\Scripts' which is not on PATH.
Consider adding this directory to PATH or, if you prefer to suppress this warning, use --no-warn-script-location.
WARNING: The script spacy.exe is installed in 'C:\Users\user_\AppData\Roaming\Python\Python36\Scripts' which is not on PATH.
Consider adding this directory to PATH or, if you prefer to suppress this warning, use --no-warn-script-location.
Successfully installed MarkupSafe-2.0.1 blis-0.7.5 catalogue-2.0.6 contextvars-2.4 cymem-2.0.6 immutables-0.16 jinja2-3.0.3 langcodes-3.3.0 murmurhash-1.0.6 pathy-0.6.1 preshed-3.0.6 pydantic-1.8.2 spacy-3.2.1 spacy-legacy-3.0.8 spacy-loggers-1.0.1 srsly-2.4.2 sudachidict-core-20210802.post1 sudachipy-0.6.2 thinc-8.0.13 typer-0.4.0 wasabi-0.9.0
WARNING: You are using pip version 21.1.2; however, version 21.3.1 is available.
You should consider upgrading via the 'C:\Program Files\Python36\python.exe -m pip install --upgrade pip' command.

Enterキーを押すと、インストールが開始され、上記のように「Successfully installed」と表示されます。これが表示されれば、spacyが正常にインストールされたことになります。

なお、今回はspacyのバージョン3.2.1をインストールしました。

コメント

タイトルとURLをコピーしました