[root@localhost ~]# yum -y install zlib-devel bzip2-devel openssl-devel ncurses-devel sqlite-devel readline-devel tk-devel gdbm-devel db4-devel libpcap-devel xz-devel
[root@localhost ~]# yum install libffi-devel -y
官网:https://www.python.org/downloads/
[root@localhost ~]# wget https://www.python.org/ftp/python/3.7.4/Python-3.7.4.tgz
个人习惯安装在/usr/local/python3(具体安装位置看个人喜好)
[root@localhost ~]# mkdir -p /usr/local/python3
[root@localhost ~]# tar -zxvf Python-3.7.4.tgz
[root@localhost ~]# cd Python-3.7.4
[root@localhost ~]# ./configure --prefix=/usr/local/python3
[root@localhost ~]# make
[root@localhost ~]# make install
[root@localhost ~]# ln -s /usr/local/python3/bin/python3 /usr/bin/python3
[root@localhost ~]# vim ~/.bash_profile
# .bash_profile
# Get the aliases and functions
if [ -f ~/.bashrc ]; then
. ~/.bashrc
fi
# User specific environment and startup programs
PATH=$PATH:$HOME/bin:/usr/local/python3/bin
export PATH
[root@localhost ~]# source ~/.bash_profile
[root@localhost ~]# python3 -V
Python 3.6.1
[root@localhost ~]# pip3 -V
pip 9.0.1 from /usr/local/python3/lib/python3.6/site-packages (python 3.6)
# 如果不行的话在创建一下pip3的软链接
[root@localhost ~]# ln -s /usr/local/python3/bin/pip3 /usr/bin/pip3
丰富的第三方库是python的优势所在,为了更加方便的安装第三方库,使用pip命令,我们需要进行相应的安装。
命令如下:
[root@localhost ~]#wget --no-check-certificate https://pypi.python.org/packages/source/s/setuptools/setuptools-19.6.tar.gz#md5=c607dd118eae682c44ed146367a17e26
[root@localhost ~]#tar -zxvf setuptools-19.6.tar.gz
[root@localhost ~]#cd setuptools-19.6
[root@localhost ~]#python3 setup.py build
[root@localhost ~]#python3 setup.py install
可能遇见的报错
命令如下:
[root@localhost ~]#wget --no-check-certificate https://pypi.python.org/packages/source/p/pip/pip-8.0.2.tar.gz#md5=3a73c4188f8dbad6a1e6f6d44d117eeb
[root@localhost ~]#tar -zxvf pip-8.0.2.tar.gz
[root@localhost ~]#cd pip-8.0.2
[root@localhost ~]#python3 setup.py build
[root@localhost ~]#python3 setup.py install
[root@localhost ~]#pip3 install paramiko
可能遇到的报错:
1.报这个错:pip is configured with locations that require TLS/SSL, however the ssl module in Python is not available.
解决办法:执行以下操作
yum install openssl
yum install openssl-devel
cd python3.6.1
make && make install
2.执行 pip3 install paramiko 报错
解决办法:执行 pip install --upgrade pip