如何安装特定补丁号版本的 Python?

如何安装特定补丁号版本的 Python?

这里的问题告诉我如何安装特定版本的 iexy

我想安装特定版本的 Python xyz - 例如 3.6.3 - 而 Ubuntu 18.04 中的默认版本是 Python 3.6.8。

有没有办法安装特定补丁号的 Python 版本?

我尝试了相关问题中选择的答案,但无法正确安装。

sudo apt install python3.6.3
Reading package lists... Done
Building dependency tree       
Reading state information... Done
E: Unable to locate package python3.6.3
E: Couldn't find any package by glob 'python3.6.3'
E: Couldn't find any package by regex 'python3.6.3'

我可以安装特定版本,但不能安装补丁号

sudo apt install python3.5
Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following additional packages will be installed:
  libpython3.5-minimal libpython3.5-stdlib python3.5-minimal
Suggested packages:
  python3.5-venv python3.5-doc binfmt-support
The following NEW packages will be installed:
  libpython3.5-minimal libpython3.5-stdlib python3.5 python3.5-minimal
0 upgraded, 4 newly installed, 0 to remove and 501 not upgraded.
Need to get 4,113 kB of archives.
After this operation, 22.5 MB of additional disk space will be used.
Do you want to continue? [Y/n] n
Abort.
sudo apt install python3.5.2
Reading package lists... Done
Building dependency tree       
Reading state information... Done
E: Unable to locate package python3.5.2
E: Couldn't find any package by glob 'python3.5.2'
E: Couldn't find any package by regex 'python3.5.2'

答案1

sudo apt-get install libssl-dev openssl
wget https://www.python.org/ftp/python/3.5.0/Python-3.5.0.tgz
tar xzvf Python-3.5.0.tgz
cd Python-3.5.0
./configure
make
sudo make install

答案2

这有点晚了,但是你可以使用类似的工具,而不是自己从源代码安装pyenv来处理这个问题。例如:

pyenv install 3.9.8
pyenv local 3.9.8  # Activate Python 3.9 for the current project or
pyenv global 3.9.8  # Activate Python 3.9 globaly

阅读有关 pyenv 的更多信息这里

相关内容