下载Python3.10的相关方法及问题解决
一、采用apt-get安装
sudo apt-get update
sudo apt install software-properties-common -y
sudo add-apt-repository ppa:deadsnakes/ppa
sudo apt-get install -y python3.10
sudo apt-get install -y python3.10-devcurl -sS https://bootstrap.pypa.io/get-pip.py | python3.10
sudo apt-get install -y python3.10-distutils
sudo ln -sf /usr/bin/python3.10 /usr/bin/python3
二、官网安装
PYTHON_VERSION="3.10.0"
PYTHON_TGZ="Python-${PYTHON_VERSION}.tgz"
PYTHON_URL="https://www.python.org/ftp/python/${PYTHON_VERSION}/${PYTHON_TGZ}"
PYTHON_INSTALL_DIR="/usr/local" sudo apt-get install -y libffi-dev zlib1g-dev
wget https://www.python.org/ftp/python/3.10.0/Python-3.10.0.tgz
tar -xzf "${PYTHON_TGZ}"
cd "Python-${PYTHON_VERSION}" ./configure --prefix="${PYTHON_INSTALL_DIR}"
make -j "$(nproc)"
sudo make altinstall
cd ..
rm -rf "Python-${PYTHON_VERSION}" "${PYTHON_TGZ}"
python3.10 -m ensurepip --upgrade
sudo cp /usr/lib/python3/dist-packages/lsb_release.py /usr/local/lib/python3.10/
最开始我采用的apt-get安装,但最近不知道为什么突然报错unable to locate package python3.10-dev,所以改成官网安装了
问题
1.subprocess.CalledProcessError: Command ‘(‘lsb_release‘, ‘-a‘)‘ returned non-zero exit status 1
问题原因是python路径下缺少 ‘lsb_release.py’ 模块
只需要找到报错路径,将lsb_release.py复制到报错路径下就可以了
所以添加了sudo cp /usr/lib/python3/dist-packages/lsb_release.py /usr/local/lib/python3.10/
参考https://blog.csdn.net/p1279030826/article/details/111573774