CentOS 7 (Fedora EPEL 7) 下安装python3.4 matplotlib显示问题

来源:互联网 发布:虚拟货币网站源码 编辑:程序博客网 时间:2024/06/05 22:46

python的matplotlib如果使用pip安装,默认的backends为Agg,为图片输出。如果使用eclipse+pydev的方式编译会导致matplotlib无输出。

此时需要修改python3.4下site-packages/matplotlib/mpl-data/matplotlibrc 中的backend设置,改为Qt4Agg输出。

在CentOS 7中使用Qt4Agg输出需要使用PySide。

安装PySide需要cmake和qmake(至少Qt4的qmake)

因为机子中装了google-chrome,导致默认qmake为3.3,pip安装PySide时找不到合适版本的qmake

此时pip download下载PySide

解压后 进入文件夹,运行python3.4 setup.py bdist_wheel --qmake=/usr/bin/qmake-qt4

(其中可能需要安装python的wheel功能先,即pip3 install wheel)

参考官方安装链接:http://pyside.readthedocs.io/en/latest/building/linux.html

然后在文件夹下dist子文件夹下找到whl文件

使用pip3 install ./dist/*.whl进行安装

完成PySide的安装,matplotlib可以使用了

但是PySide不支持3.4以上版本,需要用到python3.5 或者 3.6 的需要采用其他的matplotlib 的backends的输出方法

0 0