如何在/usr/bin中直接安装python 3.8?

How to install python 3.8 directly in /usr/bin?

正在尝试从 CentOS 7.9 中的源代码安装 python 3.8。

默认安装的 python 是 2.7.5,位于 /usr/bin。

sudo yum install gcc openssl-devel bzip2-devel libffi-devel zlib-devel
sudo cd /opt
sudo wget https://www.python.org/ftp/python/3.8.12/Python-3.8.12.tgz
sudo tar xzf Python-3.8.12.tgz
cd Python-3.8.12
sudo ./configure --enable-optimizations
sudo make install

我以为 make install 会在 /usr/bin 中创建 python3,但事实并非如此。

默认情况下,CPython 在 /usr/local/bin/python 中安装编译的 python 二进制文件。 (源代码:https://github.com/python/cpython/blob/main/configure#L571)您可以手动指定前缀为 configure --prefix=/usr.