LoginSignup
3
2

More than 1 year has passed since last update.

NumPy と matplotlib の環境構築

Last updated at Posted at 2014-12-23

最近話題の機械学習系ですが、Pythonの一つの分野として確立しつつあります。PyDataというイベントも盛んに行われています。

CentOS 6.x に NumPy と matplotlib の環境構築を行います。

事前準備

CentOS に Development Tools をインストール

その他yumで必要なものをインストール

... 後報
$ sudo yum install freetype-devel

インストール

Python2.7.9
$ cd /home/cmscom/tmp
$ wget https://www.python.org/ftp/python/2.7.9/Python-2.7.9.tgz
$ tar zxvf Python-2.7.9.tgz
$ cd Python-2.7.9
$ ./configure
$ make
$ sudo make install

以下にインストール

/usr/local/lib/python2.7

PIPとvirtualenvのインストール

$ wget https://bootstrap.pypa.io/get-pip.py
$ sudo /usr/local/bin/python get-pip.py
$ sudo pip install virtualenv
$ cd /home/cmscom
$ virtualenv python
$ ./python/bin/pip install numpy
$ ./python/bin/pip install nltk
$ ./python/bin/pip install matplotlib
$ ./python/bin/pip install ipython[notebook]

インストールでトラブル

Mac OS上の別環境にNLTKのインストールをしていたらトラブルが起きました。経緯と解決方法を記載しておきます。

AttributeError: 'module' object has no attribute 'finders' 

エラーの内容を見ると NLTKのsetup.pyで、以下の処理を行っている部分でエラーが出ています。

nltk/setup.py
from setuptools.command import sdist
del sdist.finders[:]

インストール環境の setuptools のバージョンを調べると、 setuptools-11.0 がインストールされていました。

同様の現象が報告されていました。

NLTKのバグ報告
https://github.com/nltk/nltk/issues/824

setuptoolsのバグ報告
https://bitbucket.org/pypa/setuptools/issue/322/failure-installing-nltk-300-using

インストールを進めるために以下を行いました。

$ ./python/bin/pip install setuptools==9.1 

一応これで解決!!

本質的な問題

NLTK側で、以下を実行していますが、これが問題です。

del sdist.finders[:]

詳しくわかりませんが以前のsetuptoolsを用いるときには必要だったのかと思います。
setuptoolsでVer.10以降に変更が加えられたようで、NLTK側での対応と上手くマッチしていないように思えます。

2009年の記事でこのあたりのことが語られています。
http://rhodesmill.org/brandon/2009/eby-magic/

setuptoolsでの出来事なので、 @aodag氏 か @shimizukawa氏の見解が欲しいところです。

3
2
1

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
3
2