Ubuntu20.04默认apt最高只能安装到python3.9,ros2的autoware对python3.10的新特性有依赖,因此需要升级到3.10+版本。
本文讲解升级python3.10以及配套的pip24.2版本的方法:
# 1.安装python 3.10
sudo add-apt-repository ppa:deadsnakes/ppa
sudo apt update
sudo apt install python3.10
sudo update-alternatives --install /usr/bin/python3 python3 /usr/bin/python3.10 1
sudo update-alternatives --config python3
python --version
python 3.10.15
# 2.安装pip24.2 with python3.10
sudo apt install python3.10-distutils
curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py
python3.10 get-pip.py
pip --version
pip 24.2 from /home/work/.local/lib/python3.10/site-packages/pip (python 3.10)
python3 -m pip --version
pip 24.2 from /home/work/.local/lib/python3.10/site-packages/pip (python 3.10)
pip list