Ubuntu下配置python3.7和pip3

查看系统版本信息:

uname -a

查看python版本信息:

python -V

阿里云默认安装的是python 2.7 所以需要安装python3

先更新:

sudo apt-get update

安装编译环境

sudo apt-get install zlib1g-dev libbz2-dev libssl-dev libncurses5-dev libsqlite3-dev libreadline-dev tk-dev libgdbm-dev libdb-dev libpcap-dev xz-utils libexpat1-dev liblzma-dev libffi-dev libc6-dev

先建立一个文件夹用来存放

cd ~

mkdir software

chmod -R 777 ./software

cd ./software

mkdir python

chmod -R 777 ./python

下载python3.7.1

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

解压文件:

tar zxvf Python-3.7.2.tgz

cd ./Python-3.7.2/

sudo mkdir -p /usr/local/python3

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

make

sudo make install

查看版本

python3 -V

pip3 -V

安装pip3

sudo apt install python3-pip

rm -rf /usr/bin/python3

rm -rf /usr/bin/pip3

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

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

你可能感兴趣的:(Ubuntu下配置python3.7和pip3)