2
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

Condaで入れたSpacyでモデルをダウンロードしようとすると吐かれるエラー 'spacy' is a package and cannot be directly executed を解決する

Posted at

環境

Python 3.6.5 |Anaconda, Inc.
spacy=2.0.11

問題

Spacyの英語のモデルを使いたかった

conda install spacy
python -m spacy download en

しかし

/path_to_anaconda/bin/python: No module named spacy.__main__; 'spacy' is a package and cannot be directly executed

なんとspacyはパッケージだから直接実行できないと。

解決方法

condaを諦めてpipでインストールする。

pip install spacy

環境はAnacondaベースのためpip使って大丈夫だろうかと思いましたが、最早やむなし。動くことが大事。
condaとpip:混ぜるな危険

やったこと

1. condaでインストールしたSpacyとさよなら

conda uninstall spacy

2. pipでSpacyを入れるために入れたり消したり

distributed 1.21.8 requires msgpack, which is not installed.

pip install msgpack
Cannot uninstall 'preshed'. It is a distutils installed project and thus we cannot accurately determine which files belong to it which would lead to only a partial uninstall.

conda uninstall preshed
Cannot uninstall 'murmurhash'. It is a distutils installed project and thus we cannot accurately determine which files belong to it which would lead to only a partial uninstall.

conda uninstall murmurhash

3. pipでSpacyをインストール

pip install spacy
python -m spacy download en
python
>>> import spacy
>>> spacy.load('en')
<spacy.lang.en.English object at 0x7f9609368eb8>
2
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?