6
6

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.

scikit-learnのインストール(Mac OS X)

Last updated at Posted at 2016-09-20

Mac OS X でのインストール方法#

pipを利用して簡単インストール.

pip install scikit-learn

インストールは完了.しかし,実際にインポートしようとすると以下のようなエラーが出力.

> import sklearn

Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/Library/Python/2.7/site-packages/sklearn/__init__.py", line 57, in <module> from .base import clone
File "/Library/Python/2.7/site-packages/sklearn/base.py", line 11, in <module>
from .utils.fixes import signature File "/Library/Python/2.7/site-packages/sklearn/utils/__init__.py", line 10, in <module>
from .murmurhash import murmurhash3_32
File "numpy.pxd", line 155, in init sklearn.utils.murmurhash (sklearn/utils/murmurhash.c:5029) 
ValueError: numpy.dtype has the wrong size, try recompiling

ここを参照に解決を試みるも,うまくいかない.numpyのバージョンが合っていないようだったので,下のコードでインポートのパスを調べ,関連のディレクトリを削除後,再度numpyをインストールしたところ,無事インポートすることができた.

import numpy

print numpy.__file__ #importするファイルのパスを表示

追記
pip install したパッケージをimport できないときの対応でも類似の事象が報告されていました.結局pipがインストールしたパスと,pythonがインポートの際に見に行くパスが違うことが原因っぽいですね.

6
6
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
6
6

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?