阿里云CentOS安装python3

安装相关包

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

 

创建安装目录

mkdir -p /usr/local/python3

 

下载python3

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

解压下载的文件

tar -zxvf Python-3.6.1.tgz

编译安装

cd Python-3.6.1

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

make && make install

注意:prefix后的安装路径是之前常见的/usr/local/python3

建立python3的软链

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

配置环境变量

将/usr/local/python3/bin加入PATH中

vim ~/.bash_profile

PATH=$PATH:$HOME/bin:/usr/local/python3/bin

令配置文件生效

验证是否安装成功

python3 -Vpython

安装pip3

创建软连接

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

安装python3自带的pip3

pip3 install --upgrade pip

 

 

 

 

 

 

 

 

 

 

 

你可能感兴趣的:(环境搭建)