Linux 编译安装 Python3


本文档适用 Python 3.9及以上版本。

1. 提前安装依赖

yum install -y gcc ncurses-devel gdbm-devel xz-devel sqlite-devel tk-devel uuid-devel readline-devel bzip2-devel libffi-devel openssl11 openssl11-devel

2. 设置编译 FLAG

  • AWS AMI:
export CFLAGS=$(pkg-config --cflags libssl11)
export LDFLAGS=$(pkg-config --libs libssl11)
  • CentOS:
export CFLAGS=$(pkg-config --cflags openssl11)
export LDFLAGS=$(pkg-config --libs openssl11)

3. 编译安装 Python3

cd src
wget https://www.python.org/ftp/python/3.11.3/Python-3.11.3.tar.xz
tar xf Python-3.11.3.tar.xz
cd Python-3.11.3
./configure --prefix=/App/python --disable-test-modules
make -j$(nproc)
make install
echo 'export PATH=/App/python/bin:$PATH' >> /etc/profile
source /etc/profile

猜你喜欢

转载自blog.csdn.net/dongsong1117/article/details/130282784
今日推荐