- 下载依赖包
yum install -y python-devel \
mysql-devel \
libxml2 \
libxml2-devel \
libxslt* \
zlib \
zlib-devel \
gcc \
gcc-c++ \
openssl \
openssl-devel \
openldap \
openldap-devel
- python 下载
wget https://www.python.org/ftp/python/3.6.5/Python-3.6.5.tgz
- 解压包
tar xf Python-3.6.5.tgz
- 创建目录
mkdir /usr/local/python3
- 编译安装
cd Python-3.65
./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
- 安装py3所需要的包
pip3 install requests lxml pymysql redis beautifulsoup4
- 命令行输入python3 看看是否安装成功
[root@rzxc_test ~]# python3
Python 3.6.5 (default, Oct 17 2018, 09:53:56)
[GCC 4.8.5 20150623 (Red Hat 4.8.5-28)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>>