迷你安裝後更換yum源:
http://mirrors.163.com/.help/CentOS7-Base-163.repo
http://mirrors.163.com/.help/CentOS6-Base-163.repo
1.下載repo檔案
yum install wget
wget http://mirrors.163.com/.help/CentOS6-Base-163.repo
2.備份並替換系統的repo檔案
cd /etc/yum.repos.d/
mv CentOS-Base.repo CentOS-Base.repo.bak
mv CentOS6-Base-163.repo CentOS-Base.repo
3.執行yum源更新
yum clean all
yum makecache
yum -y update
4.安裝開發工具:
yum groupinstall -y 'development tools'
5.安裝python依賴包:
yum install -y zlib-devel bzip2-devel openssl-devel xz-libs ncurses-devel
6.下載python新版本:
到https://www.python.org/ftp/python/ 網站找到新版本的下載連結
wget https://www.python.org/ftp/python/2.7.9/Python-2.7.9.tgz
ca python2.7.9
./configure --prefix=/usr/local
make all && make altinstall
make clean
make distclean
編譯安裝的不需要安裝python-devel
7.編譯安裝完畢。輸入下面命令查看版本
#/usr/local/bin/python2.7 –V
建立軟串連指向到當前系統預設python命令的bin目錄(安裝完預設會把/usr/locl/bin添加到PATH環境中)
#ln -s /usr/local/bin/python2.7 /usr/local/bin/python
#/usr/local/bin/python –V
此時查詢顯示的版本是:2.7.9。可是此時yum不能正常使用,需要修改yum的設定檔。
#vi /usr/bin/yum
把檔案頭部的#!/usr/bin/python改成#!/usr/bin/python2.6 //改為之前的老版本號碼儲存退出。
8.安裝easy_install擴充
#wget https://pypi.python.org/packages/source/s/setuptools/setuptools-18.0.1.tar.gz
wget https://bitbucket.org/pypa/setuptools/raw/bootstrap/ez_setup.py
sudo /usr/local/bin/python2.7 ez_setup.py
sudo /usr/local/bin/easy_install-2.7 pip
9.安裝新版本Git(版本過低會報401錯誤):
git依賴以下包:
$ yum install curl-devel expat-devel gettext-devel openssl-devel zlib-devel perl-ExtUtils-MakeMaker package
$ wget https://codeload.github.com/git/git/zip/master
$ cd git-master
$ make prefix=/usr/local all
$ sudo make prefix=/usr/local install
9.當安裝Git報錯時:usr/bin/perl Makefile.PL PREFIX='/usr/local/git' INSTALL_BASE='' --localedir='/usr/local/git/share/locale'
Can't locate ExtUtils/MakeMaker.pm in @INC (@INC contains: /usr/local/lib64/perl5 /usr/local/share/perl5 /usr/lib64/perl5/vendor_perl /usr/share/perl5/vendor_perl /usr/lib64/perl5 /usr/share/perl5 .) at Makefile.PL line 3.
BEGIN failed--compilation aborted at Makefile.PL line 3.
make[1]: *** [perl.mak] Error 2
make: *** [perl/perl.mak] Error 2
yum install perl-ExtUtils-MakeMaker package
10.升級完Python再安裝其他包,可能會出現以下錯誤
import pycurl
ImportError: pycurl: libcurl link-time ssl backend (nss) is different from compile-time ssl backend (openssl)
解決的方法就是:
pip uninstall pycurl
export PYCURL_SSL_LIBRARY=nss
easy_install pycurl
需要注意的是之前用pip安裝的,然後卸載掉以後,一定要用easy_install安裝才可以匯入成功
11.參考;
https://github.com/h2oai/h2o-2/wiki/Installing-python-2.7-on-centos-6.3.-Follow-this-sequence-exactly-for-centos-machine-only