Installing Python3.4 and the SciPy stack on CentOS

来源:互联网 发布:ipad版淘宝没有微淘 编辑:程序博客网 时间:2024/05/20 00:13

    在Linux环境下配置python3.4的开发环境,折腾了一段时间,寻得一篇文章,事情终于完美解决。在原作者的基础上,写上了自己的一些见解,希望对大家有所帮助!

原创网址:  https://edwards.sdsu.edu/research/installing-python3-4-and-the-scipy-stack-on-centos/

经测试:该可以实现在centos6.7和centos7下,实现python2.7.5与相关包numpy、scipy、matplotlib的安装;以及实现python3.4与相关包numpy、scipy、matplotlib的安装.

注意的要点:

1. 如安装python3.4相关包,相关依赖包必须要在python2.7的环境下安装完成后,再切换到python3.4的环境,实现相关包的安装。否则,直接在python3.4的环境下,安装相关包会报错。python环境切换以及pip调用方式,如下

(1)建立软链接
[root@localhost bin]# mv /usr/bin/python /usr/bin/python2.7.5
[root@localhost bin]# ln -s /usr/local/bin/python3.4 /usr/bin/python
注:
/usr/local/bin/python3.4:新安装的位置
/usr/bin/python:原始安装的位置
(2)原始的pip调用方式
[root@localhost bin]# pip3.4 search numpy

2、 切换python2.7.5为python3.4.4时,并解决yum无法使用的问题,如下:
    #vim /usr/bin/yum
      将文本首行:
   #!/usr/bin/python  修改为(=>):  #!/usr/bin/python2.7.6

3、进行scipy安装时,会提示“sh: g++: command not found”,此时要检查是否安装有g++,如果没有,在python2.7.5环境下先进行安装。步骤如下:

(1)在发现该错误时,先在系统中确认是否缺失相对应的包:

          rpm -qa | grep "g++"

(2)在确认系统未安装之后,查询可安装的相对应的功能的包:

         yum whatprovides "*/g++"

(3)根据提供的包,选择适合系统的进行安装,比如:

        yum install gcc-c++-4.4.7-4.el6.x86_64

(4)安装结束之后,新开terminal,重新继续初始操作;

4、另外,scipy安装耗时会相当长,我的电脑安装完成要1小时左右,需耐心等待。

5、对于参考文献中给出的 libpng-devel方法,不可用。我采用的是在python2.7.5环境下,yum install libpng-devel.x86_64完成了依赖包的安装,

[root@localhost opt]# yum search libpng-devel
Loaded plugins: fastestmirror, langpacks
Loading mirror speeds from cached hostfile
 * base: mirrors.skyshe.cn
 * extras: mirrors.skyshe.cn
 * updates: mirrors.skyshe.cn
============================================================= N/S matched: libpng-devel ==============================================================
libpng-devel.i686 : Development tools for programs to manipulate PNG image format files
libpng-devel.x86_64 : Development tools for programs to manipulate PNG image format files

  Name and summary matches only, use "search all" for everything.
[root@localhost opt]# yum install libpng-devel.x86_64

最后,再采用

              [root@localhost opt]# pip3.4 install matplotlib

完成了matplotlib的安装。

这样,三大常见的python包全部安装完成,使用pip freeze确认:

[root@localhost opt]# pip3.4 freeze
cycler==0.10.0
matplotlib==1.5.1
numpy==1.11.0
pyparsing==2.1.1
python-dateutil==2.5.2
pytz==2016.3
scipy==0.17.0
six==1.10.0

正文:

Installing Python3.4 and the SciPy stack on CentOS

My Linux experiences are primarily associated with Ubuntu and, until recently, have never had to work with an rpm style distro. I know installing software on either one is generally the same despite the use of different package managers, but there were a few online resources I frequently used in which I could no longer reference.

I want to share the operations I performed to install Python2.7 and Python3.4 on CentOS. CentOS is pre installed with Python2.6 but this version does not include some of the nice features 2.7/3.4 provide. Below are mostly the instructions to install the SciPy stack on 3.4, but they should be able to apply to 2.7 by using the proper version of pip.

I’ve provided the two web links I used at the top under REFERENCES 

### REFERENCES #### http://wiki.guibin.info/?p=133 ## http://g0o0o0gle.com/install-python-3-4-1-centos-6/ #yum groupinstall "Development tools"sudo yum install zlib-devel bzip2-devel openssl-devel ncurses-devel sqlite-devel readline-devel tk-devel gdbm-devel db4-devel libpcap-devel xz-develsudo vim /etc/ld.so.confadd '/usr/local/lib'# INSTALL PYTHON 2.7wget http://python.org/ftp/python/2.7.6/Python-2.7.6.tar.xztar xvf Python-2.7.6.tar.xzcd Python-2.7.6sudo ./configure --prefix=/usr/local --enable-shared LDFLAGS="-Wl,-rpath /usr/local/lib"sudo makesudo make altinstall# INSTALL PYTHON 3.4wget http://python.org/ftp/python/3.4.1/Python-3.4.1.tar.xztar xvf Python-3.4.1.tar.xzcd Python-3.4.1sudo ./configure --prefix=/usr/local --enable-shared LDFLAGS="-Wl,-rpath /usr/local/lib"sudo makesudo make altinstall# This will install pip3.4 already# INSTALL NUMPYsudo yum install lapack lapack-devel blas blas-develsudo /usr/local/bin/pip3.4 install numpy# INSTALL SCIPYsudo /usr/local/bin/pip3.4 install scipy# SETUP INSTALL FOR MATPLOTLIB# Get, build, install freetypewget http://download.savannah.gnu.org/releases/freetype/freetype-2.5.3.tar.gztar xvzf freetype-2.5.3.tar.gzcd freetype-2.5.3sudo ./configuresudo makesudo make install# Get, build, install libpngwget http://mirror.centos.org/centos/6/os/x86_64/Packages/libpng-devel-1.2.49-1.el6_2.x86_64.rpmsudo rpm -Uvh libpng-devel-1.2.49-1.el6_2.x86_64.rpm# INSTALL MATPLOTLIB# Matplotlib source can be obtained through sourceforge or gitgit clone git@github.com:matplotlib/matplotlib.gitcd matplotlib/python3.4 setup.py buildsudo /usr/local/bin/python3.4 setup.py install
This entry was posted in Lab blog and tagged centos, matplotlib, numpy, python2.7, python3.4, scipyon August 27, 2014 by Daniel Cuevas.
0 0
原创粉丝点击