ubuntu安装python指定版本

安装指定版本需要在https://www.python.org/ftp/python/中选择版本,以python3.8.4为例:

#1、安装依赖
apt-get install -y gcc make build-essential libssl-dev zlib1g-dev libbz2-dev libreadline-dev libsqlite3-dev wget curl llvm libncurses5-dev libncursesw5-dev xz-utils tk-dev libffi-dev liblzma-dev
#2、下载python3.8.4
wget https://www.python.org/ftp/python/3.8.4/Python-3.8.4.tgz
#3、解压、编译与安装
tar -xzf Python-3.8.4.tgz
cd Python-3.8.4
sudo ./configure --enable-optimizations --prefix=/usr/local/
make
make install
#4、设置软连接
ln -s -f /usr/local/bin/python3.6/bin/python3.6 /usr/bin/python3.8
ln -s -f /usr/local/bin/python3.6/bin/pip3.6 /usr/bin/pip3.8

你可能感兴趣的:(ubuntu,ubuntu,python,bash)