Ubuntu 22.04 Release Date
Ubuntu 22.04 Jammy Jellyfish is scheduled for release on April 21, 2022
If you’re ready to use Ubuntu 22.04 Jammy Jellyfish, you can either upgrade your current Ubuntu system or download Ubuntu 22.04 and install it from ISO.
Ubuntu22 还有几个月就要来到了,自带的 Python 版本将是 3.10 ,但是我想在 Ubuntu20.04 上也想用呢!
Ubuntu20.04 自带的 Python 版本是 3.8 ,如果想安装 python3.9 可以用该命令:
sudo apt install python3.9
Ubuntu20.04 的仓库没有收录 python3.10 ,那我们就自己从源码编译安装吧!
准备工作,先安装依赖项
sudo apt update
sudo apt upgrade
sudo apt install gcc
sudo apt install g++
sudo apt install libffi-dev
sudo apt install build-essential checkinstall
sudo apt install libreadline-gplv2-dev libncursesw5-dev libssl-dev libsqlite3-dev tk-dev libgdbm-dev libc6-dev libbz2-dev
我把 python3.10 源码压缩包下载到~/Downloads
目录下
我把 python3.10 安装到~/opt
目录下
下载 Python 源代码
到 ~/opt
目录下执行下面的命令下载源代码的压缩包
sudo curl -O https://www.python.org/ftp/python/3.10.1/Python-3.10.1.tgz
解压缩
tar zxvf ./Python-3.10.1.tgz
查看
╭─bot@amd-5700G ~/Downloads
╰─➤ ll | grep Python
6439688 drwxr-xr-x 16 - - bot bot 7 Dec 2021 Python-3.10.1
6439619 .rw-rw-r-- 1 25M 48952 bot bot 2 Jan 13:58 Python-3.10.1.tgz
准备好安装路径
cd ~/opt
mkdir python3.10.1
安装
cd ~/Downloads/Python-3.10.1
sudo ./configure --enable-optimizations --prefix=/home/bot/opt/python3.10.1
sudo make -j8
sudo make install
默认只用一个处理器编译,这太慢了,我们多进程并行处理:sudo make -j8 && make install,-j8 表示用 8 个处理器,如果你的处理器只有4个就改成4
安装好了就是下面的样子
╭─bot@amd-5700G ~/opt/python3.10.1
╰─➤ ll
inode Permissions Links Size Blocks User Group Date Modified Name
6301327 drwxr-xr-x 2 - - bot bot 2 Jan 14:25 bin
7873931 drwxr-xr-x 3 - - root root 2 Jan 14:25 include
6301328 drwxr-xr-x 4 - - bot bot 2 Jan 14:25 lib
7998483 drwxr-xr-x 3 - - root root 2 Jan 14:25 share
╭─bot@amd-5700G ~/opt/python3.10.1
╰─➤ cd bin
╭─bot@amd-5700G ~/opt/python3.10.1/bin
╰─➤ ll
inode Permissions Links Size Blocks User Group Date Modified Name
6305556 lrwxrwxrwx 1 9 0 root root 2 Jan 14:25 2to3 -> 2to3-3.10
6305551 .rwxr-xr-x 1 118 8 root root 2 Jan 14:25 2to3-3.10
6305554 lrwxrwxrwx 1 8 0 root root 2 Jan 14:25 idle3 -> idle3.10
6305549 .rwxr-xr-x 1 116 8 root root 2 Jan 14:25 idle3.10
6305561 .rwxr-xr-x 1 246 8 root root 2 Jan 14:25 pip3
6305562 .rwxr-xr-x 1 246 8 root root 2 Jan 14:25 pip3.10
6305555 lrwxrwxrwx 1 9 0 root root 2 Jan 14:25 pydoc3 -> pydoc3.10
6305550 .rwxr-xr-x 1 101 8 root root 2 Jan 14:25 pydoc3.10
6305552 lrwxrwxrwx 1 10 0 root root 2 Jan 14:25 python3 -> python3.10
6305553 lrwxrwxrwx 1 17 0 root root 2 Jan 14:25 python3-config -> python3.10-config
6301329 .rwxr-xr-x 1 24M 46296 root root 2 Jan 14:25 python3.10
6305548 .rwxr-xr-x 1 3.1k 8 root root 2 Jan 14:25 python3.10-config
╭─bot@amd-5700G ~/opt/python3.10.1/bin
╰─➤ ./python3.10
Python 3.10.1 (main, Jan 2 2022, 14:23:57) [GCC 9.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>>