centos安装python3.x

1、下载python安装包
```
wget https://www.python.org/ftp/python/3.8.5/Python-3.8.5.tar.xz
```
2、安装编译软件及依赖包
```
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 -y libffi-devel zlib1g-dev
yum install zlib* -y
```
3、解压安装包
```
tar -xvf Python-3.8.5.tar.xz
```
4、创建安装目录,方便以后查找或卸载
```
mkdir /usr/local/python3
```
5、编译、安装
```
cd Python-3.8.5/
./configure --prefix=/usr/local/python3 --enable-optimizations --with-ssl
make && make install

--prefix:指定安装的路径,不指定的话,安装过程中可能软件所需要的文件复制到其他不同目录, 删除软件很不方便,复制软件也不方便.
--enable-optimizations:第二个可以提高python10%-20%代码运行速度.
--with-ssl:第三个是为了安装pip需要用到ssl,后面报错会有提到.
```
6、创建软链接,方便使用。(或者添加都环境变量PATH中)
```
ln -s /usr/local/python3/bin/pip3 /usr/bin/pip3
ln -s /usr/local/python3/bin/python3 /usr/bin/python3
```
7、查看安装情况
```
python3 -V
pip3 -V
```

 
posted @ 2020-09-05 10:42  小明大强  阅读(227)  评论(0编辑  收藏  举报