1.安装python3替换python2.7
[root@Python src]# wget https://www.python.org/ftp/python/3.5.4/Python-3.5.4.tar.xz [root@Python src]# yum install zlib-devel zlib openssl [root@Python src]# tar xf Python-3.5.4.tar.xz #可能需要一些库文件 [root@Python src]# yum groupinstall "Development tools" [root@Python src]# yum install readline-devel [root@Python src]# cd Python-3.5.4/ [root@Python Python-3.5.4]# ./configure --prefix=/usr/local/python3 --with-ssl [root@Python Python-3.5.4]# make && make install [root@Python ~]# cp /usr/bin/python2.7 /usr/bin/python2.7.bak [root@Python ~]# rm -f /usr/bin/python [root@Python ~]# ln -s /usr/local/python3/bin/python3.5 /usr/bin/python [root@Python ~]# vi /usr/bin/yum #!/usr/bin/python2 [root@Python ~]# vi /usr/libexec/urlgrabber-ext-down #! /usr/bin/python2.7 [root@Python ~]# python Python 3.5.4 (default, Feb 6 2018, 02:52:38) [GCC 4.8.5 20150623 (Red Hat 4.8.5-4)] on linux Type "help", "copyright", "credits" or "license" for more information. >>>
2. 安装pip3
#安装setuptools [root@Python src]# wget --no-check-certificate https://pypi.python.org/packages/source/s/setuptools/setuptools-19.6.tar.gz#md5=c607dd118eae682c44ed146367a17e26 [root@Python src]# yum install zlib-devel zlib [root@Python src]# tar xf setuptools-19.6.tar.gz [root@Python src]# cd setuptools-19.6/ [root@Python setuptools-19.6]# python setup.py build [root@Python setuptools-19.6]# cd /usr/local/src/Python-3.5.4/ [root@Python Python-3.5.4]# make && make install #安装pip3 [root@Python src]# wget https://pypi.python.org/packages/11/b6/abcb525026a4be042b486df43905d6893fb04f05aac21c32c638e939e447/pip-9.0.1.tar.gz [root@Python src]# tar xf pip-9.0.1.tar.gz [root@Python src]# cd pip-9.0.1 [root@Python pip-9.0.1]# python setup.py build [root@Python pip-9.0.1]# python setup.py install #基本安装完成 [root@Python pip-9.0.1]# python -m pip install paramiko pip is configured with locations that require TLS/SSL, however the ssl module in Python is not available. Collecting paramiko Could not fetch URL https://pypi.python.org/simple/paramiko/: There was a problem confirming the ssl certificate: Can't connect to HTTPS URL because the SSL module is not available. - skipping Could not find a version that satisfies the requirement paramiko (from versions: ) No matching distribution found for paramiko [root@Python pip-9.0.1]# yum install openssl-devel [root@Python bin]# ln -s /usr/local/python3/bin/pip3 /usr/bin/pip