安裝python2.7
wget https://www.Python.org/ftp/Python/2.7.8/Python-2.7.8.tgz
tar xvf Python-2.7.8.tgz
cd Python-2.7.8
./configure –prefix=/usr/local/python27
make
make install
mv /usr/bin/python /usr/bin/python_old
ln -s /usr/local/python27/bin/python /usr/bin/
python # 查看版本
解決YUM無法使用的問題
vim /usr/bin/yum
首行#!/usr/bin/python 替換為老版本python #!/usr/bin/python2.4 注意可能為2.6
pip模塊安裝
yum install python-pip # centos安裝pip
sudo apt-get install python-pip # ubuntu安裝pip
pip官方安裝腳本
wget https://raw.github.com/pypa/pip/master/contrib/get-pip.py
python get-pip.py
pip編譯安裝
wget http://pypi.python.org/packages/source/s/setuptools/setuptools-0.6c11.tar.gz
tar zxvf setuptools-0.6c11.tar.gz
cd setuptools-0.6c11
python setup.py build
python setup.py install
wget https://pypi.python.org/packages/source/p/pip/pip-1.5.6.tar.gz#md5=01026f87978932060cc86c1dc527903e
tar zxvf pip-1.5.6.tar.gz
cd pip-1.5.6
python setup.py build
python setup.py install
加載環境變量
vim /etc/profile
export PATH=/usr/local/python27/bin:$PATH
. /etc/profile
pip install Package # 安裝包 pip install requests
pip show –files Package # 查看安裝包時安裝了哪些文件
pip show –files Package # 查看哪些包有更新
pip install –upgrade Package # 更新一個軟件包
pip uninstall Package # 卸載軟件包