我的环境: python 2.7.10, zepplin 0.61
1. 需要python支持Tkinter. 这需要重新编译安装python
先查询系统中tk的版本:
[root@n2 ~]# rpm -qa | grep tk
tk-devel-8.5.7-5.el6.x86_64
tkinter-2.6.6-66.el6_8.x86_64
tk-8.5.7-5.el6.x86_64
下载python2.7.10源码,修改Modules/Setup.dist, 去掉如下所示的注释, 并修改tk的版本为8.5:
.......
# *** Always uncomment this (leave the leading underscore in!):
_tkinter _tkinter.c tkappinit.c -DWITH_APPINIT \
# *** Uncomment and edit to reflect where your Tcl/Tk libraries are:
-L/usr/local/lib \
# *** Uncomment and edit to reflect where your Tcl/Tk headers are:
-I/usr/local/include \
# *** Uncomment and edit to reflect where your X11 header files are:
-I/usr/X11R6/include \
# *** Or uncomment this for Solaris:
.......
# *** Uncomment and edit to reflect your Tcl/Tk versions:
-ltk8.5 -ltcl8.5 \
......
2. 安装pip
因为自己编译的python不带有pip,我下的pip版本是 9.0.1.
下载pip,然后解压后进入pip目录,运行 python setup.py install安装pip
3. 安装libpng
我是下载 libpng-1.6.26.tar.xz 后,解压再 make install
4. 安装freetype
我是下载 freetype-2.6.5.tar.gz 后, 解压再 make install
5. 安装 matplotlib 1.5.0
pip --no-cache-dir install -U -i https://pypi.mirrors.ustc.edu.cn/simple matplotlib==1.5.0
注意:我一开始使用默认最新的1.5.3版本安装后,无法使用!
6. 安装 py4j
pip install py4j
5. 重启zeppelin,搞定!
注意: 以上步骤需要root 权限或者sudo.