参考:
1,在192.168.0.65装python2.7和PIP
#ssh 192.168.0.65
升级到python2.7
#cd /usr/local
#wget https://www.python.org/ftp/python/2.7.10/Python-2.7.10.tgz
# tar zxvf Python-2.7.10.tgz
# cd Python-2.7.10
# mkdir /usr/local/Python2.7
# ./configure --prefix=/usr/local/Python2.7
#make && make install
#which python
# mv /usr/bin/python /usr/bin/python_old
# ln -s /usr/local/Python2.7/bin/python2.7 /usr/bin/python
参考文档http://www.cnblogs.com/lanxuezaipiao/archive/2012/10/21/2732864.html
安装pip之前需要先安装zlib,setuptools
安装zlib
#yum -y install zlib报错了,如下:
No module named yum
这个错误的原因是我升级了python,导致yum无法使用。
参考文档 :http://blog.csdn.net/ei__nino/article/details/8495295
解决办法:
# vi /usr/bin/yum
#!/usr/bin/python_old
//文件第一行内容改为 #!/usr/bin/python_old,因为我把旧的python重命名为python_old了。而yum匹配的是旧的python。
# /sbin/service yum-updatesd restart
# yum -y install zlib zlib-devel
//安装成功!但是安装setuptools依旧报错。需要重新编译python。
参考文档 http://www.idjango.com/content/0/
下面重新编译python
# cd /usr/local/Python-2.7.10
# ./configure --prefix=/usr/local/Python2.7
#make && make install
安装setuptools
# cd /usr/local
# curl -O https://pypi.python.org/packages/source/s/setuptools/setuptools-2.0.tar.gz
# tar zxvf setuptools-2.0.tar.gz
# cd setuptools-2.0
#python setup.py build
#python setup.py install//成功
安装PIP
PIP官网 https://pypi.python.org/pypi/pip
#cd /usr/local
# curl -O https://pypi.python.org/packages/source/p/pip/pip-7.1.2.tar.gz#md5=3823d2343d9f3aaab21cf9c917
# curl -O https://pypi.python.org/packages/source/p/pip/pip-7.1.2.tar.gz
用wget下载时会报错,这里改用curl -O即可,这2个命令下载的包都是对的
# tar zxvf pip-7.1.2.tar.gz
# cd pip-7.1.2
# python setup.py install
# ln -s /usr/local/Python2.7/bin/pip /usr/bin/pip
//pip默认安装到了/usr/local/Python2.7/bin/下面
#pip //测试pip
报错啦:ImportError: cannot import name HTTPSHandler
原因在于openssl,openssl-devel两个文件包未正确安装
解决办法:
#yum install openssl openssl-devel -y
继续报错,然后我重新编译了python和pip。OK不再报错了。