Python学习-centos7.0下matplotlib安装及问题解决
2015-07-19 16:22
901 查看
Windows下matplotlib的安装,前面已经介绍了Python学习-windows安装Python以及matplotlib.pyplot包,由于现在在服务器上跑程序,需要在centos 7.0上安装,那么就做个笔记。
首先matplotlib是需要numpy先行包支持的,这里,我已经安装了numpy,下面安装matplotlib。
matplot需要一些其他软件支持
这时需要安装freetype 和 png 这两个库
然后再继续安装,前提是安装了pip:Python学习-安装pip和scikit-learn
然后执行下列命令即可
最后使用pip安装报错:
参考资料:
将
然后执行
就可以成功安装了了。
然后需要还原
执行Python的使用,将pyplot导入的时候,需要做下处理:
参考:
资料来源:http://chewpichai.blogspot.com/2008/01/display-error-matplotlib.html (需***–推介红杏)。
说明,上面命令安装出错,也可以使用
测试:
但是使用pyplot时还是报错了。。。使用的方法还是在使用代码时引用pyplot时修改下:
最后,安装pyplot库花了比较长的时间,一直出问题,有点恶心了。不过最后还是解决了。
首先matplotlib是需要numpy先行包支持的,这里,我已经安装了numpy,下面安装matplotlib。
matplot需要一些其他软件支持
这时需要安装freetype 和 png 这两个库
yum install freetype freetype-devel python-freetype yum install libpng libpng-devel python-pypng
然后再继续安装,前提是安装了pip:Python学习-安装pip和scikit-learn
然后执行下列命令即可
pip install matplotlib
最后使用pip安装报错:
/usr/bin/ld: /usr/local/lib/libpython2.7.a(abstract.o): relocation R_X86_64_32S against `_Py_NotImplementedStruct' can not be used when making a shared object; recompile with -fPIC /usr/local/lib/libpython2.7.a: could not read symbols: Bad value
参考资料:
将
/usr/local/bin目录下的
libpython2.7.a暂时保存为备份文件
cd /usr/local/bin mv libpython2.7.a libpython2.7.a.tmp
然后执行
pip install matplotlib
就可以成功安装了了。
然后需要还原
libpython2.7.a
mv libpython2.7.a.tmp libpython2.7.a
执行Python的使用,将pyplot导入的时候,需要做下处理:
import matplotlib matplotlib.use('Agg') from matplotlib.pyplot import *
参考:
DISPLAY error matplotlib When error occur about this "$DISPLAY not set" when you run Python code that use matplotlib this happened because your matplotlib backend is set to FltkAgg, GTK, GTKAgg, GTKCairo, TkAgg , Wx or WxAgg they required a GUI that why error occur. To solve this you must specific other backend that not required GUI (Agg, Cairo, PS, PDF or SVG ) when use matplotlib like this In code import matplotlib matplotlib.use('Agg') In command line use -d option Python subplot_demo.py -dAgg Remember when call savefig('filename') don't give it extension this will handle by backend that you specific e.g Agg will create file filename.png source from --> http://matplotlib .sourceforge.net/backends.html
资料来源:http://chewpichai.blogspot.com/2008/01/display-error-matplotlib.html (需***–推介红杏)。
说明,上面命令安装出错,也可以使用
yum安装,安装命令
yum install python-matplotlib
测试:
[root@master bin]# python Python 2.7.5 (default, Jun 17 2014, 18:11:42) [GCC 4.8.2 20140120 (Red Hat 4.8.2-16)] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> import matplotlib >>>
但是使用pyplot时还是报错了。。。使用的方法还是在使用代码时引用pyplot时修改下:
import matplotlib matplotlib.use('Agg') from matplotlib.pyplot import *
最后,安装pyplot库花了比较长的时间,一直出问题,有点恶心了。不过最后还是解决了。
相关文章推荐
- linux下安装storm
- linux下的 一些常识
- Linux 磁盘管理
- 在linux下安装jdk
- vmware centOS 开机进度条 卡死 Determining IP Information for eth0...
- linux中运行一个二进制的文件
- LINUX中system()函数详解
- 在VMware下建立一个linux和Windows共享的文件夹
- LINUX中fork()函数详解
- Linux strace命令(转)
- 如何查看/修改Linux时区和时间
- Centos 6.5 配置hadoop2.7.1
- 在Linux上实现摄像头中的霍夫圆检测
- linux——ssh服务器的配置
- Linux忘记ROOT密码后的处理方式
- c实现linux下的数据库备份
- linux命令,系统安全相关命令--passwd
- Linux系统中时间相关命令(cal,date,hwclock)
- linux awk命令详解,使用system来内嵌系统命令,批量github,批量批下载视频
- Centos 下Python 升级遇到的zlib,ssl 的问题