在Ubuntu24.04上编译Python3.12.1

本文所有命令以root用户执行,若非root用户,请注意适时使用sudo提权。 安装编译需要的依赖包 apt update apt install -y \ build-essential \ wget \ libssl-dev \ zlib1g-dev \ libncurses-dev \ lib

本文所有命令以root用户执行,若非root用户,请注意适时使用sudo提权。

安装编译需要的依赖包

apt update
apt install -y \
build-essential \
wget \
libssl-dev \
zlib1g-dev \
libncurses-dev \
libreadline-dev \
libsqlite3-dev \
libgdbm-dev \
libdb5.3-dev \
libbz2-dev \
libexpat1-dev \
liblzma-dev \
tk-dev \
libffi-dev \
libgmp3-dev \
libbz2-dev \
libgdbm-compat-dev

下载并编译安装Python3.12.1

curl https://www.python.org/ftp/python/3.12.1/Python-3.12.1.tgz -o /tmp/Python-3.12.1.tgz
tar -xf /tmp/Python-3.12.1.tgz -C /tmp
cd /tmp/Python-3.12.1
./configure --enable-optimizations --prefix=/usr/local/python-3.12.1/
make -j$(nproc)
make altinstall

参考资料

  1. package management - Unable to get libmpdec-dev from remote repository on Ubuntu 24.04using apt-get - Ask Ubuntu

  2. Linux(Ubuntu)系统下编译源码安装新版 Python 3.X_xietansheng的博客-CSDN博客_python3编译安装

  3. 如何在Ubuntu24.04系统上安装Python 3.10:PPA和源码编译两种方法-tgoo分享

LICENSED UNDER CC BY-NC-SA 4.0
Comment