【问题标题】:Install python on Linux from source with custom paths使用自定义路径从源代码在 Linux 上安装 python
【发布时间】:2021-06-30 12:57:01
【问题描述】:
我找到了如何从源代码安装它的教程,但在所有教程中都使用了默认配置。
我想在与操作系统所在分区不同的分区上安装一个新的 python 版本,所以不在 /usr/bin 和默认路径中。
因此,如果我从备份中恢复主分区,则无需重新安装新的 python 版本。也很容易(小改动)将像 VisualStudioCode 或 Pycharm 这样的 IDE (重新)定向到新的 python 版本。(可能只是添加到路径)。
我不想安装工具来做到这一点。
【问题讨论】:
标签:
python
python-3.x
linux
opensuse
【解决方案1】:
这个过程非常简单,假设你想在你的 $HOME 中安装
# 0) Download python source and extracted it to $HOME/tmp/Python3.9.2 directory
# 1)
mkdir $HOME/usr
# 2)
cd $HOME/tmp/Python3.9.2
# 3)
./configure --prefix=$HOME/usr && make
# 4) Now python is built in $HOME/tmp/Python3.9.2, give it a test, then
make install
# Now you should have $HOME/usr/bin/python ready to use.