在Debian系统中升级Python版本可以通过多种方法实现,以下是一些常见的方法和步骤:
sudo apt update
sudo apt install build-essential libncursesw5-dev libssl-dev libsqlite3-dev tk-dev libgdbm-dev libc6-dev libbz2-dev libffi-dev zlib1g-dev
wget https://www.python.org/ftp/python/3.12.0/Python-3.12.0.tgz
tar xzf Python-3.12.0.tgz
cd Python-3.12.0
./configure --enable-optimizations
make altinstall
python3.12 --version
curl https://pyenv.run | bash
~/.bashrc
、~/.bash_profile
或~/.zshrc
文件中:export PYENV_ROOT="$HOME/.pyenv"
export PATH="$PYENV_ROOT/bin:$PATH"
if command -v pyenv 1/dev/null 2>&1; then
eval "$(pyenv init --path)"
eval "$(pyenv init -)"
fi
pyenv install 3.12.0
pyenv local 3.12.0
pyenv global 3.12.0
pyenv versions
sudo update-alternatives --list python
sudo update-alternatives --install /usr/bin/python python /usr/bin/python3.12 1
sudo update-alternatives --install /usr/bin/python python /usr/bin/python3.4 2
sudo update-alternatives --config python
sudo update-alternatives --remove python /usr/bin/python3.4