python3编译安装配置

安装编译依赖&工具

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
yum install libffi-devel -y

下载软件包&解压软件包

wget https://www.python.org/ftp/python/3.8.2/Python-3.8.2.tgz
tar -zxvf Python-3.8.1.tgz

配置安装环境

cd Python-3.8.1.tgz
./configure --prefix=/usr/local/python3

编译安装

make && make install

页面提示:Successfully installed pip-21.2.4 setuptools-58.1.0 安装成功

配置环境变量并生效

vim  /etc/profile

点击键盘“o”键在文档最后新增如下代码

#python3.8  configuration
PATH=$PATH:/usr/local/python3/bin:
export PATH

保存并退出vim

点击键盘ESC,输入:wq回车
使配置生效

source /etc/profile

验证python3安装是否生效

python3 -V

查看本机自带python2是否可用

python -V

自带python已生效

注:如果不想用自带的2.7.5 可以进行升级。只需在/etc/profile文件中 新增python2*的路径即可

PATH=$PATH:/usr/local/python3/bin:/usr/local/python2.7.15/bin
上一篇:linux 部署python


下一篇:C# .NET Framework 3.5 下 Thread 与 Semaphore 的简单例子