Ubuntu下安装Python主要有以下三种方法:
sudo apt update更新包列表。sudo apt install python3安装Python 3,若需特定版本,如python3.9,则输入sudo apt install python3.9。python3 --version验证安装是否成功。sudo add-apt-repository ppa:deadsnakes/ppa。sudo apt update。sudo apt install python3.13。python3.13 --version验证。sudo apt update,然后sudo apt install -y build-essential zlib1g-dev libncurses5-dev libgdbm-dev libnss3-dev libssl-dev libreadline-dev libffi-dev curl libbz2-dev。wget https://www.python.org/ftp/python/3.x.x/Python-3.x.x.tgz(替换为所需版本号)。tar -xf Python-3.x.x.tgz,进入目录cd Python-3.x.x。./configure --enable-optimizations,make -j $(nproc)。sudo make altinstall。python3.x --version。