网站首页 > python 正文

Ubuntu安装Python3.9

admin 2024-01-03 09:23:35 python 113 ℃
正文

Ubuntu20安装Python 3.9


sudo apt update

sudo apt upgrade


sudo apt install build-essential libssl-dev zlib1g-dev libncurses5-dev libncursesw5-dev libreadline-dev libsqlite3-dev libgdbm-dev libdb5.3-dev libbz2-dev libexpat1-dev liblzma-dev zlib1g-dev libffi-dev wget curl llvm libncurses5-dev xz-utils tk-dev libxml2-dev libxmlsec1-dev libffi-dev liblzma-dev libssl-dev


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

tar -xf Python-3.9.13.tgz

cd Python-3.9.13

./configure --enable-optimizations

make -j 4

sudo make altinstall



apt install python3-pip


apt install pip3


设置及修改默认python版本

sudo update-alternatives --install /usr/bin/python python /usr/bin/python2.7 1

sudo update-alternatives --install /usr/bin/python python /usr/local/bin/python3.9 1

sudo update-alternatives --config python


设置及修改默认python3版本

sudo update-alternatives --install /usr/bin/python3 python3 /usr/local/bin/python3.9 1

sudo update-alternatives --config python3


python3软连接

sudo ln -s /usr/bin/python3 /usr/bin/python


本文TAG:

蓝色枫叶