Ubuntu 源码安装

  1. APT安装依赖包

    1
    sudo apt install libffi-dev python3-dev libssl-dev libbz2-dev libncurses5-dev libncursesw5-dev libbz2-dev zlib1g-dev liblzma-dev -y
  1. 去官网下合适版本的源码包:

    1
    qs dl https://www.python.org/ftp/python/3.9.4/Python-3.9.4.tar.xz
  2. 解压

    1
    qs untar Python-3.9.4.tar.xz
  3. 进入文件夹并配置安装

    1
    2
    3
    cd Python-3.9.4
    ./configure --enable-optimizations --prefix=/usr/local/python3
    make && sudo make install
  4. 创建软链接

    1
    2
    sudo ln -snf /usr/local/python3/bin/python3 /usr/bin/python3
    sudo ln -snf /usr/local/python3/bin/pip3 /usr/bin/pip3

可能的问题

lsb_release returned non-zero exit status 1

1
rm /usr/bin/lsb_release

MacOS

官网有dmg的安装包,按流程走就行。

Windows

官网有安装包,按流程走,注意添加环境变量。