使用SCL , CentOS6.5下(不升级系统和内核) 搭建Python2.7 + gcc4.8编译环境

[ 2017-04-19 10:57:21 | 作者: admin ]
字号: | |
http://www.jianshu.com/p/acf398baf6ed

在安装编译某些node模块时,需要Python2.7和gcc4.8编译环境,为了不影响别的代码程序,需要在不更新的情况下搭建环境,步骤如下。
        注:不可运行 sudo yum update,会将系统升级。

1.安装SCL软件集

scl是一个第三方软件源,软件支持很丰富。那么通过它安装的软件,不会影响系统原来的软件和配置,每次使用时,只需要用命令切换一下。

安装命令:sudo yum install centos-release-scl
切换命令:scl enable <scl-package> <command>
注:enable 激活后只在当前terminal下有用,其他情况均为系统默认环境
2.安装Python2.7

        安装python2.7
        sudo yum install python27
        通过scl切换至此版本
        scl enable python27 bash
        安装Python2.7的pip
        cd /opt/rh/python27/root/usr/bin/ # cd to the directory where SCL installs python
        sudo LD_LIBRARY_PATH=$LD_LIBRARY_PATH ./easy_install-2.7 pip
        sudo LD_LIBRARY_PATH=$LD_LIBRARY_PATH ./pip2.7 install requests
        验证安装
        python --version
        Python 2.7.8

3.升级gcc至4.8

        查看系统版本
        $ cat /etc/centos-release CentOS release 6.5 (Final)
        导入CERN's GPG key
        sudo rpm --import http://ftp.scientificlinux.org/linux/scientific/5x/x86_64/RPM-GPG-KEYs/RPM-GPG-KEY-cern
        将库信息保存为/etc/yum.repos.d/slc6-devtoolset.repo
        wget -O /etc/yum.repos.d/slc6-devtoolset.repo http://linuxsoft.cern.ch/cern/devtoolset/slc6-devtoolset.repo
        进行安装
        sudo yum install devtoolset-2
        使用scl切换至4.8版本
        scl enable devtoolset-2 bash
        验证安装
        gcc --version gcc (GCC) 4.8.2 20140120 (Red Hat 4.8.2-15) Copyright (C) 2013 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
        g++ (GCC) 4.8.2 20140120 (Red Hat 4.8.2-15) Copyright (C) 2013 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
        gfortran --version GNU Fortran (GCC) 4.8.2 20140120 (Red Hat 4.8.2-15) Copyright (C) 2013 Free Software Foundation, Inc. GNU Fortran comes with NO WARRANTY, to the extent permitted by law. You may redistribute copies of GNU Fortran under the terms of the GNU General Public License. For more information about these matters, see the file named COPYING

至此,通过scl enable命令切换至需要的环境再编译,就可以顺利通过。
[最后修改由 admin, 于 2017-04-19 10:58:47]
评论Feed 评论Feed: http://blog.xg98.com/feed.asp?q=comment&id=2396

这篇日志没有评论。

此日志不可发表评论。