服务器安装python软件包及配置环境变量

1、服务器安装python

1>、安装依赖

yum install openssl-devel bzip2-devel expat-devel gdbm-devel readline-devel sqlite-devel

2>、CentOS系统执行命令

yum install wget -y

3>、python官网下载

wget https://www.python.org/ftp/python/3.8.0/Python-3.8.0rc1.tgz

4>、解压tgz包

tar -zxvf Python-3.8.0rc1.tgz

5>、把python移到/usr/local下面

mv Python-3.8.0rc1 /usr/local

6>、添加配置文件

准备编译环境

yum -y install zlib-devel bzip2-devel openssl-devel ncurses-devel sqlite-devel readline-devel tk-devel libffi-devel gcc make

配置安装目录

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

编译安装

make

make install

应用配置

./configure --enable-optimizations

7>、建立软链接

ln -s /usr/local/python3.8/bin/python3.8 /usr/bin/python3.8

ln -s /usr/local/python3.8/bin/pip3.8 /usr/bin/pip3

ls -l /usr/bin/

8>、pip

查看:pip --version

下载: curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py

安装:python3 get-pip.py

yum install -y gcc

yum install httpd

9>、环境变量

vi /etc/profile

export PATH=$PATH:/usr/local/Python3/bin

source /etc/profile

要是能按照markdown的格式美化一下就更好了

今天安装的时候随记的 :grinning: