LoginSignup
3
3

More than 5 years have passed since last update.

【備忘録】CentOS6.7+Python2.7+matplotlibでハマった

Posted at

かなりハマってしまったので備忘録として残す。

参考
Installing Tkinter for Python 2.7

環境

  • CentOS6.7
  • Python2.7

エラー

matplotlib を利用しようとするとエラーがでる。
正確にはmatplotlibのバックエンドで使用しているTkinterのインポートでエラーが発生する。

import Tkinter

ImportError: No module named '_tkinter'
$ yum search tkinter

python2-tktable.x86_64 : TkTable wrapper for Python 2.x with Tkinter
python34-tkinter.i686 : A GUI toolkit for Python 3
python34-tkinter.x86_64 : A GUI toolkit for Python 3
tkinter.x86_64 : A graphical user interface for the Python scripting language

なるほど...yum install tkinterでいいじゃないかと思ったのだが、ここで問題となったのがCentOS6.7のデフォルトのsystem pythonは2.6とういこと。
システムのPythonが2.6ということはyumを含むRedhatのツールの多くはPython 2.6に依存している。
なのでyum install tkinterをした所でPython2.7では使えないし、他のパッケージはPython3向けのものしかない。

結論としては、探し物はIUC Communityリポジトリにあるらしい
IUCommunityリポジトリのインストール

$ wget https://dl.iuscommunity.org/pub/ius/stable/CentOS/6/x86_64/ius-release-1.0-14.ius.centos6.noarch.rpm
$ rpm -Uvh ius-release-1.0-14.ius.centos6.noarch.rpm
$ yum search tkinter

tkinter.x86_64 : A graphical user interface for the Python scripting language
tkinter27.x86_64 : A graphical user interface for the Python scripting language

あとはyum install tkinter27で終わり。

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