python安装参考这篇文章:
centos下python2-6升级为2-7
python 默认版本 2.6 和 2.7的替换:
root [~] mv /usr/bin/python /usr/bin/python2.6
root [~] ln -s /usr/local/bin/python2.7 /usr/bin/python
root [~] ln -s /usr/local/bin/python2.7 /usr/bin/python
修改/usr/bin/yum,将第一行的#!/usr/bin/python修改成#!/usr/bin/python2.6。
执行python -V 如果出现错误error while loading shared libraries: libpython2.7.so.1.0: cannot open shared object file: No such file or directory。
编辑配置文件/etc/ld.so.conf添加新的一行内容/usr/local/lib,保存退出,然后
root [~] /sbin/ldconfig
root [~] /sbin/ldconfig -v
root [~] /sbin/ldconfig -v
安装pip:
root [~] wget https://bootstrap.pypa.io/get-pip.py
root [~] python get-pip.py
root [~] ln -s /usr/local/bin/pip2.7 /usr/bin/pip
root [~] python get-pip.py
root [~] ln -s /usr/local/bin/pip2.7 /usr/bin/pip
测试pip:
root [~] pip install dnspython
root [~] python
Python 2.7.12 (default, Sep 26 2016, 10:47:25)
[GCC 4.4.7 20120313 (Red Hat 4.4.7-17)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import dns
>>> print dns
<module 'dns' from '/usr/local/lib/python2.7/site-packages/dns/__init__.pyc'>
>>> exit(0)
root [~] python
Python 2.7.12 (default, Sep 26 2016, 10:47:25)
[GCC 4.4.7 20120313 (Red Hat 4.4.7-17)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import dns
>>> print dns
<module 'dns' from '/usr/local/lib/python2.7/site-packages/dns/__init__.pyc'>
>>> exit(0)
1 Pingback