【python3】CentOS7.x上Python3.8.3的编译安装

一、实验背景


CentOS7.x上默认python版本为2.7.5,有时候,我们的一些程序需要高版本3.x版本python。

如果想要使用高版本的python,又不动原来版本的python,需要编译安装一个3.x版本。


二、下载python源码包、编译工具和依赖


#  wget https://www.python.org/ftp/python/3.8.3/Python-3.8.3.tar.xz

#  yum -y install  make gcc zlib-devel openssl-devel bzip2-devel ncurses-devel gdbm-devel readline-devel sqlite-devel libffi-devel libpcap-devel libdbi-devel tk-devel xz-devel sysstat

#   xz -d Python-3.8.3.tar.xz 

#  tar -xvf Python-3.8.3.tar

#  cd Python-3.8.3/

# ./configure --prefix=/usr/local/python3

#  make 

#  make install


# /usr/local/python3/bin/python3.8 -V


三、安装python模块


# ll /usr/local/python3/lib/


# /usr/local/python3/bin/pip3 install pymysql

# find /usr/local/python3/ -name "*mysql*"

# ll /usr/local/python3/lib/python3.8/site-packages/

从上面输出可以看出,编译安装的python,安装模块的保存目录为 /usr/local/python3/lib/python3.8/site-packages 

如果其他机器需要3.x版本python及所需模块,可以将  /usr/local/python3 打包过去释放。


四、python2.7.5的相关目录


# rpm -qa | grep 2.7.5

# rpm -ql python-2.7.5 | grep bin

# rpm -ql python-libs



五、参考


Python-3.7.5安装

https://blog.csdn.net/Jarvyn/article/details/106736531


Linux(Ubuntu)系统下编译源码安装 Python 3.7

https://blog.csdn.net/xietansheng/article/details/84791703


python3.7编译安装

https://zhuanlan.zhihu.com/p/76253402

https://www.cnblogs.com/shangping/p/10756718.html

你可能感兴趣的:(【python3】CentOS7.x上Python3.8.3的编译安装)