- 下载安装包
https://www.python.org/ftp/python/3.10.9/Python-3.10.9.tgz
- 解压
tar xvzf Python-3.10.9.tgz
- 配置
cd Python-3.10.9
./configure prefix=/usr/local/python3.10 --enable-optimizations --with-system-ffi --with-ensurepip=install
make -j$(nproc) && make install
make clean
rm -rf /opt/Python-3.10.9
echo 'export PATH=$PATH:/usr/local/python3.10/bin' >> ~/.bashrc
source ~/.bashrc
# 配置默认为 python3
rm -rf /usr/bin/python3
rm -rf /usr/bin/pip3
ln -s /usr/local/python3.10/bin/python3.10 /usr/bin/python3.10
ln -s /usr/local/python3.10/bin/pip3 /usr/bin/pip3.10
--with-system-ffi:
ModuleNotFoundError: No module named '_ctypes'
- 确认 _ctypes 是否可用
python3.10 -c "import _ctypes; print('_ctypes is available')"

image.png