龙空技术网

学习python之环境搭建2——基于Linux

fangel 64

前言:

目前朋友们对“linuxpythonzlib”大约比较注意,你们都需要了解一些“linuxpythonzlib”的相关知识。那么小编在网摘上汇集了一些有关“linuxpythonzlib””的相关文章,希望你们能喜欢,大家快快来学习一下吧!

前面步骤中下载的CentOS8.3内置的python版本如下:

[root@localhost ~]$ python3 -V

Python 3.6.8

当前可以获取到的最新python版本是3.9.2,地址:

1、依赖包下载和安装

如果CentOS是最小安装,则需要安装如下依赖包:

yum -y install wget

yum -y install setup

yum -y install perl

yum install openssl-devel -y

yum install zlib-devel -y

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

yum install libffi-devel -y

本文前面下载的CentOS只需要安装如下即可

yum -y install perl

yum install openssl-devel -y

yum -y groupinstall "Development tools"

yum install zlib* -y

yum install libffi-devel -y

2、python下载

[root@localhost ~]# wget

3、解压

[root@localhost ~]# tar -zxvf Python-3.9.2.tgz

[root@localhost ~]# ls

anaconda-ks.cfg original-ks.cfg Python-3.9.2 Python-3.9.2.tgz

[root@localhost ~]# chmod 777 Python-3.9.2

4、编译和安装

#创建一个目录

[root@localhost ~]# mkdir /usr/local/python392

#进入解压后的目录

[root@localhost ~]# cd Python-3.9.2

#指定安装目录为/usr/local/python392

[root@localhost Python-3.9.2]# ./configure --prefix=/usr/local/python392 --enable-optimizations --with-ssl

# make编译,相当于把源码包里面的代码编译成linux服务器可以识别的代码

# make install编译安装,先进行make,执行完成之后,才开始执行make install

[root@localhost Python-3.9.2]#make && make install

#如果出现如下的标记,则表明安装成功

Installing collected packages: setuptools, pip

Successfully installed pip-20.2.3 setuptools-49.2.1

5、配置环境变量

[root@localhost Python-3.9.2]# ln -s /usr/local/python392/bin/python3 /usr/local/bin/python3

[root@localhost Python-3.9.2]# ln -s /usr/local/python392/bin/pip3 /usr/local/bin/pip3

[root@localhost Python-3.9.2]# pip3 install --upgrade pip

6、检查是否安装成功

[root@localhost ~]# python3 -V

Python 3.9.2

标签: #linuxpythonzlib