检查centos7上的python环境
# 在控制台上执行 python 命令,可以看到输出的版本号
[root@VM_105_217_centos Python-3.6.2]# python
Python 2.7.5 (default, Aug 4 2017, 00:39:18)
[GCC 4.8.5 20150623 (Red Hat 4.8.5-16)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
安装
安装依赖包
yum -y groupinstall "Development tools"
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
下载python源码,安装
wget https://www.python.org/ftp/python/3.6.2/Python-3.6.2.tar.xz
mkdir /usr/local/python3
tar -xvJf Python-3.6.2.tar.xz
cd Python-3.6.2
./configure --prefix=/usr/local/python3
make && make install
ln -s /usr/local/python3/bin/python3 /usr/bin/python3
ln -s /usr/local/python3/bin/pip3 /usr/bin/pip3
安装开发所需要的依赖包
pip3 install urllib3 Crypto pycrypto PyMySQL sqlalchemy