py3.7.9安装
操作系统原有py
[pythondemo@localhost ~]$ cat /etc/centos-release CentOS Linux release 7.4.1708 (Core) [pythondemo@localhost ~]$ 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.
下载py3.3.9
curl https://www.python.org/ftp/python/3.7.9/Python-3.7.9.tgz
安装依赖
yum -y install zlib-devel bzip2-devel openssl-devel ncurses-devel sqlite-devel readline-devel tk-devel gcc make
解压缩包
tar -zxvf Python-3.7.9.tgz
把解压后的python移到/usr/local
mv Python-3.7.9 /usr/local/bin # 进入解压后的目录 cd /usr/local/bin/Python-3.7.9
编译py3.7.9
# 配置 ./configure # 编译 make # 安装 make install
新建软连接
# 查看原有软链接 ll -d /usr/bin/python lrwxrwxrwx. 1 root root 7 Aug 4 2020 /usr/bin/python -> python2 # 删除原有的软链接 rm -rf /usr/bin/python # 新建软链接 ln -s /usr/local/bin/Python-3.7.9 /usr/bin/python
安装完成
[pythondemo@localhost ~]$ python3 Python 3.7.9 (default, Jun 11 2023, 21:54:07) [GCC 4.8.5 20150623 (Red Hat 4.8.5-44)] on linux Type "help", "copyright", "credits" or "license" for more information. >>> quit()
## 降级urllib3至兼容旧版OpenSSL的版本:
pip3 install urllib3==1.26.6
## 添加依赖
pip3 install pandas
pip3 install lxml
pip3 install beautifulsoup4
pip3 install requests