2023年4月19日 星期三

在 Linux Mint 上安裝新版 Python 3 的問題

下午更新完 Acer D255 小筆電的 Linux Mint 後在終端機輸入 python  結果是進入 Python 2.7, 而輸入 python3 指令則是進入 Python 3.5.2 解譯器 :

tony1966@tony1966-AOD255 ~ $ python3   
Python 3.5.2 (default, Jan 26 2021, 13:30:48)
[GCC 5.4.0 20160609] on linux
Type "help", "copyright", "credits" or "license" for more information.

v.3.5 真的有點舊了, 有些好用功能不能用, 例如最近發現 math.perm() 與 math.comb() 要 3.8 版以後才支援, 所以最好能將 Python 版本提升到最新版. 我找到下面的教學文章 : 

 
我依照指引嘗試安裝 3.11 與 3.10 都因套件清單找不到這兩個版本, 降至 3.9 版就有了, 但安裝完成後卻沒在 /usr/bin 底下找到 Python3.9, 好奇怪, 先將安裝過程記錄下來, 明天有空再找看看是何原因 :


1. 更新套件清單與升版套件 :

tony1966@tony1966-AOD255 ~ $ sudo apt update
tony1966@tony1966-AOD255 ~ $ sudo apt upgrade

這兩個指令在稍早的那篇文章已做過, 參考 : 



2. 安裝必要之套件 :

中間會停下來詢問是否要繼續安裝, 輸入 y : 

tony1966@tony1966-AOD255 ~ $ sudo apt install wget build-essential libncursesw5-dev libssl-dev libsqlite3-dev tk-dev libgdbm-dev libc6-dev libbz2-dev libffi-dev zlib1g-dev 
Reading package lists... Done
Building dependency tree       
Reading state information... Done
libc6-dev is already the newest version (2.23-0ubuntu11.3).
wget is already the newest version (1.17.1-1ubuntu1.5).
The following additional packages will be installed:
  g++ g++-5 libexpat1-dev libfontconfig1-dev libfreetype6-dev libice-dev libpng12-dev libsm-dev libstdc++-5-dev libtinfo-dev
  libxext-dev libxft-dev libxrender-dev libxss-dev libxt-dev tcl-dev tcl8.6-dev tk8.6-dev x11proto-render-dev
  x11proto-scrnsaver-dev x11proto-xext-dev
Suggested packages:
  g++-multilib g++-5-multilib gcc-5-doc libstdc++6-5-dbg libice-doc ncurses-doc libsm-doc sqlite3-doc libstdc++-5-doc
  libxext-doc libxt-doc tcl-doc tcl8.6-doc tk-doc tk8.6-doc
Recommended packages:
  bzip2-doc libssl-doc
The following NEW packages will be installed:
  build-essential g++ g++-5 libbz2-dev libexpat1-dev libffi-dev libfontconfig1-dev libfreetype6-dev libgdbm-dev libice-dev
  libncursesw5-dev libpng12-dev libsm-dev libsqlite3-dev libssl-dev libstdc++-5-dev libtinfo-dev libxext-dev libxft-dev
  libxrender-dev libxss-dev libxt-dev tcl-dev tcl8.6-dev tk-dev tk8.6-dev x11proto-render-dev x11proto-scrnsaver-dev
  x11proto-xext-dev zlib1g-dev
0 upgraded, 30 newly installed, 0 to remove and 4 not upgraded.
Need to get 16.7 MB of archives.
After this operation, 69.7 MB of additional disk space will be used.
Do you want to continue? [Y/n] y   
Get:1 http://archive.ubuntu.com/ubuntu xenial-updates/main amd64 libstdc++-5-dev amd64 5.4.0-6ubuntu1~16.04.12 [1428 kB]
Get:2 http://archive.ubuntu.com/ubuntu xenial-updates/main amd64 g++-5 amd64 5.4.0-6ubuntu1~16.04.12 [8430 kB]
Get:3 http://archive.ubuntu.com/ubuntu xenial/main amd64 g++ amd64 4:5.3.1-1ubuntu1 [1504 B]                                 
Get:4 http://archive.ubuntu.com/ubuntu xenial/main amd64 build-essential amd64 12.1ubuntu2 [4758 B]                          
Get:5 http://archive.ubuntu.com/ubuntu xenial-updates/main amd64 libbz2-dev amd64 1.0.6-8ubuntu0.2 [29.0 kB]                 
Get:6 http://archive.ubuntu.com/ubuntu xenial-updates/main amd64 libexpat1-dev amd64 2.1.0-7ubuntu0.16.04.5 [115 kB]         
Get:7 http://archive.ubuntu.com/ubuntu xenial-updates/main amd64 zlib1g-dev amd64 1:1.2.8.dfsg-2ubuntu4.3 [167 kB]           
Get:8 http://archive.ubuntu.com/ubuntu xenial-updates/main amd64 libpng12-dev amd64 1.2.54-1ubuntu1.1 [183 kB]               
Get:9 http://archive.ubuntu.com/ubuntu xenial-updates/main amd64 libfreetype6-dev amd64 2.6.1-0.1ubuntu2.5 [955 kB]          
Get:10 http://archive.ubuntu.com/ubuntu xenial-updates/main amd64 libfontconfig1-dev amd64 2.11.94-0ubuntu1.1 [658 kB]       
Get:11 http://archive.ubuntu.com/ubuntu xenial/main amd64 libgdbm-dev amd64 1.8.3-13.1 [35.9 kB]                             
Get:12 http://archive.ubuntu.com/ubuntu xenial/main amd64 libice-dev amd64 2:1.0.9-1 [44.9 kB]                               
Get:13 http://archive.ubuntu.com/ubuntu xenial/main amd64 libtinfo-dev amd64 6.0+20160213-1ubuntu1 [77.4 kB]                 
Get:14 http://archive.ubuntu.com/ubuntu xenial/main amd64 libncursesw5-dev amd64 6.0+20160213-1ubuntu1 [198 kB]              
Get:15 http://archive.ubuntu.com/ubuntu xenial/main amd64 libsm-dev amd64 2:1.2.2-1 [16.2 kB]                                
Get:16 http://archive.ubuntu.com/ubuntu xenial-updates/main amd64 libsqlite3-dev amd64 3.11.0-1ubuntu1.5 [509 kB]            
Get:17 http://archive.ubuntu.com/ubuntu xenial-updates/main amd64 libssl-dev amd64 1.0.2g-1ubuntu4.20 [1347 kB]              
Get:18 http://archive.ubuntu.com/ubuntu xenial/main amd64 x11proto-xext-dev all 7.3.0-1 [212 kB]                             
Get:19 http://archive.ubuntu.com/ubuntu xenial/main amd64 libxext-dev amd64 2:1.3.3-1 [82.1 kB]                              
Get:20 http://archive.ubuntu.com/ubuntu xenial/main amd64 x11proto-render-dev all 2:0.11.1-2 [20.1 kB]                       
Get:21 http://archive.ubuntu.com/ubuntu xenial/main amd64 libxrender-dev amd64 1:0.9.9-0ubuntu1 [24.5 kB]                    
Get:22 http://archive.ubuntu.com/ubuntu xenial/main amd64 libxft-dev amd64 2.3.2-1 [45.7 kB]                                 
Get:23 http://archive.ubuntu.com/ubuntu xenial/main amd64 x11proto-scrnsaver-dev all 1.2.2-1 [25.0 kB]                       
Get:24 http://archive.ubuntu.com/ubuntu xenial/main amd64 libxss-dev amd64 1:1.2.2-1 [12.7 kB]                               
Get:25 http://archive.ubuntu.com/ubuntu xenial/main amd64 libxt-dev amd64 1:1.1.5-0ubuntu1 [394 kB]                          
Get:26 http://archive.ubuntu.com/ubuntu xenial/main amd64 tcl8.6-dev amd64 8.6.5+dfsg-2 [882 kB]                             
Get:27 http://archive.ubuntu.com/ubuntu xenial/main amd64 tcl-dev amd64 8.6.0+9 [5664 B]                                     
Get:28 http://archive.ubuntu.com/ubuntu xenial/main amd64 tk8.6-dev amd64 8.6.5-1 [682 kB]                                   
Get:29 http://archive.ubuntu.com/ubuntu xenial/main amd64 tk-dev amd64 8.6.0+9 [2964 B]                                      
Get:30 http://archive.ubuntu.com/ubuntu xenial/main amd64 libffi-dev amd64 3.2.1-4 [161 kB]                                  
Fetched 16.7 MB in 27s (617 kB/s)                                                                                            
Selecting previously unselected package libstdc++-5-dev:amd64.
(Reading database ... 224219 files and directories currently installed.)
Preparing to unpack .../libstdc++-5-dev_5.4.0-6ubuntu1~16.04.12_amd64.deb ...
Unpacking libstdc++-5-dev:amd64 (5.4.0-6ubuntu1~16.04.12) ...
Selecting previously unselected package g++-5.
Preparing to unpack .../g++-5_5.4.0-6ubuntu1~16.04.12_amd64.deb ...
Unpacking g++-5 (5.4.0-6ubuntu1~16.04.12) ...
Selecting previously unselected package g++.
Preparing to unpack .../g++_4%3a5.3.1-1ubuntu1_amd64.deb ...
Unpacking g++ (4:5.3.1-1ubuntu1) ...
Selecting previously unselected package build-essential.
Preparing to unpack .../build-essential_12.1ubuntu2_amd64.deb ...
Unpacking build-essential (12.1ubuntu2) ...
Selecting previously unselected package libbz2-dev:amd64.
Preparing to unpack .../libbz2-dev_1.0.6-8ubuntu0.2_amd64.deb ...
Unpacking libbz2-dev:amd64 (1.0.6-8ubuntu0.2) ...
Selecting previously unselected package libexpat1-dev:amd64.
Preparing to unpack .../libexpat1-dev_2.1.0-7ubuntu0.16.04.5_amd64.deb ...
Unpacking libexpat1-dev:amd64 (2.1.0-7ubuntu0.16.04.5) ...
Selecting previously unselected package zlib1g-dev:amd64.
Preparing to unpack .../zlib1g-dev_1%3a1.2.8.dfsg-2ubuntu4.3_amd64.deb ...
Unpacking zlib1g-dev:amd64 (1:1.2.8.dfsg-2ubuntu4.3) ...
Selecting previously unselected package libpng12-dev:amd64.
Preparing to unpack .../libpng12-dev_1.2.54-1ubuntu1.1_amd64.deb ...
Unpacking libpng12-dev:amd64 (1.2.54-1ubuntu1.1) ...
Selecting previously unselected package libfreetype6-dev:amd64.
Preparing to unpack .../libfreetype6-dev_2.6.1-0.1ubuntu2.5_amd64.deb ...
Unpacking libfreetype6-dev:amd64 (2.6.1-0.1ubuntu2.5) ...
Selecting previously unselected package libfontconfig1-dev:amd64.
Preparing to unpack .../libfontconfig1-dev_2.11.94-0ubuntu1.1_amd64.deb ...
Unpacking libfontconfig1-dev:amd64 (2.11.94-0ubuntu1.1) ...
Selecting previously unselected package libgdbm-dev.
Preparing to unpack .../libgdbm-dev_1.8.3-13.1_amd64.deb ...
Unpacking libgdbm-dev (1.8.3-13.1) ...
Selecting previously unselected package libice-dev:amd64.
Preparing to unpack .../libice-dev_2%3a1.0.9-1_amd64.deb ...
Unpacking libice-dev:amd64 (2:1.0.9-1) ...
Selecting previously unselected package libtinfo-dev:amd64.
Preparing to unpack .../libtinfo-dev_6.0+20160213-1ubuntu1_amd64.deb ...
Unpacking libtinfo-dev:amd64 (6.0+20160213-1ubuntu1) ...
Selecting previously unselected package libncursesw5-dev:amd64.
Preparing to unpack .../libncursesw5-dev_6.0+20160213-1ubuntu1_amd64.deb ...
Unpacking libncursesw5-dev:amd64 (6.0+20160213-1ubuntu1) ...
Selecting previously unselected package libsm-dev:amd64.
Preparing to unpack .../libsm-dev_2%3a1.2.2-1_amd64.deb ...
Unpacking libsm-dev:amd64 (2:1.2.2-1) ...
Selecting previously unselected package libsqlite3-dev:amd64.
Preparing to unpack .../libsqlite3-dev_3.11.0-1ubuntu1.5_amd64.deb ...
Unpacking libsqlite3-dev:amd64 (3.11.0-1ubuntu1.5) ...
Selecting previously unselected package libssl-dev:amd64.
Preparing to unpack .../libssl-dev_1.0.2g-1ubuntu4.20_amd64.deb ...
Unpacking libssl-dev:amd64 (1.0.2g-1ubuntu4.20) ...
Selecting previously unselected package x11proto-xext-dev.
Preparing to unpack .../x11proto-xext-dev_7.3.0-1_all.deb ...
Unpacking x11proto-xext-dev (7.3.0-1) ...
Selecting previously unselected package libxext-dev:amd64.
Preparing to unpack .../libxext-dev_2%3a1.3.3-1_amd64.deb ...
Unpacking libxext-dev:amd64 (2:1.3.3-1) ...
Selecting previously unselected package x11proto-render-dev.
Preparing to unpack .../x11proto-render-dev_2%3a0.11.1-2_all.deb ...
Unpacking x11proto-render-dev (2:0.11.1-2) ...
Selecting previously unselected package libxrender-dev:amd64.
Preparing to unpack .../libxrender-dev_1%3a0.9.9-0ubuntu1_amd64.deb ...
Unpacking libxrender-dev:amd64 (1:0.9.9-0ubuntu1) ...
Selecting previously unselected package libxft-dev.
Preparing to unpack .../libxft-dev_2.3.2-1_amd64.deb ...
Unpacking libxft-dev (2.3.2-1) ...
Selecting previously unselected package x11proto-scrnsaver-dev.
Preparing to unpack .../x11proto-scrnsaver-dev_1.2.2-1_all.deb ...
Unpacking x11proto-scrnsaver-dev (1.2.2-1) ...
Selecting previously unselected package libxss-dev:amd64.
Preparing to unpack .../libxss-dev_1%3a1.2.2-1_amd64.deb ...
Unpacking libxss-dev:amd64 (1:1.2.2-1) ...
Selecting previously unselected package libxt-dev:amd64.
Preparing to unpack .../libxt-dev_1%3a1.1.5-0ubuntu1_amd64.deb ...
Unpacking libxt-dev:amd64 (1:1.1.5-0ubuntu1) ...
Selecting previously unselected package tcl8.6-dev:amd64.
Preparing to unpack .../tcl8.6-dev_8.6.5+dfsg-2_amd64.deb ...
Unpacking tcl8.6-dev:amd64 (8.6.5+dfsg-2) ...
Selecting previously unselected package tcl-dev:amd64.
Preparing to unpack .../tcl-dev_8.6.0+9_amd64.deb ...
Unpacking tcl-dev:amd64 (8.6.0+9) ...
Selecting previously unselected package tk8.6-dev:amd64.
Preparing to unpack .../tk8.6-dev_8.6.5-1_amd64.deb ...
Unpacking tk8.6-dev:amd64 (8.6.5-1) ...
Selecting previously unselected package tk-dev:amd64.
Preparing to unpack .../tk-dev_8.6.0+9_amd64.deb ...
Unpacking tk-dev:amd64 (8.6.0+9) ...
Selecting previously unselected package libffi-dev:amd64.
Preparing to unpack .../libffi-dev_3.2.1-4_amd64.deb ...
Unpacking libffi-dev:amd64 (3.2.1-4) ...
Processing triggers for man-db (2.7.5-1) ...
Processing triggers for doc-base (0.10.7) ...
Processing 4 added doc-base files...
Registering documents with scrollkeeper...
Processing triggers for install-info (6.1.0.dfsg.1-5) ...
Setting up libstdc++-5-dev:amd64 (5.4.0-6ubuntu1~16.04.12) ...
Setting up g++-5 (5.4.0-6ubuntu1~16.04.12) ...
Setting up g++ (4:5.3.1-1ubuntu1) ...
update-alternatives: using /usr/bin/g++ to provide /usr/bin/c++ (c++) in auto mode
Setting up build-essential (12.1ubuntu2) ...
Setting up libbz2-dev:amd64 (1.0.6-8ubuntu0.2) ...
Setting up libexpat1-dev:amd64 (2.1.0-7ubuntu0.16.04.5) ...
Setting up zlib1g-dev:amd64 (1:1.2.8.dfsg-2ubuntu4.3) ...
Setting up libpng12-dev:amd64 (1.2.54-1ubuntu1.1) ...
Setting up libfreetype6-dev:amd64 (2.6.1-0.1ubuntu2.5) ...
Setting up libfontconfig1-dev:amd64 (2.11.94-0ubuntu1.1) ...
Setting up libgdbm-dev (1.8.3-13.1) ...
Setting up libice-dev:amd64 (2:1.0.9-1) ...
Setting up libtinfo-dev:amd64 (6.0+20160213-1ubuntu1) ...
Setting up libncursesw5-dev:amd64 (6.0+20160213-1ubuntu1) ...
Setting up libsm-dev:amd64 (2:1.2.2-1) ...
Setting up libsqlite3-dev:amd64 (3.11.0-1ubuntu1.5) ...
Setting up libssl-dev:amd64 (1.0.2g-1ubuntu4.20) ...
Setting up x11proto-xext-dev (7.3.0-1) ...
Setting up libxext-dev:amd64 (2:1.3.3-1) ...
Setting up x11proto-render-dev (2:0.11.1-2) ...
Setting up libxrender-dev:amd64 (1:0.9.9-0ubuntu1) ...
Setting up libxft-dev (2.3.2-1) ...
Setting up x11proto-scrnsaver-dev (1.2.2-1) ...
Setting up libxss-dev:amd64 (1:1.2.2-1) ...
Setting up libxt-dev:amd64 (1:1.1.5-0ubuntu1) ...
Setting up tcl8.6-dev:amd64 (8.6.5+dfsg-2) ...
Setting up tcl-dev:amd64 (8.6.0+9) ...
Setting up tk8.6-dev:amd64 (8.6.5-1) ...
Setting up tk-dev:amd64 (8.6.0+9) ...
Setting up libffi-dev:amd64 (3.2.1-4) ...


3. 將 PPA 添加到 Ubuntu 系統中 :

tony1966@tony1966-AOD255 ~ $ sudo add-apt-repository ppa:deadsnakes/ppa
[sudo] password for tony1966:
You are about to add the following PPA:
 This PPA contains more recent Python versions packaged for Ubuntu.

Disclaimer: there's no guarantee of timely updates in case of security problems or other issues. If you want to use them in a security-or-otherwise-critical environment (say, on a production server), you do so at your own risk.

Update Note
===========
Please use this repository instead of ppa:fkrull/deadsnakes.

Reporting Issues
================

Issues can be reported in the master issue tracker at:
https://github.com/deadsnakes/issues/issues

Supported Ubuntu and Python Versions
====================================

- Ubuntu 18.04 (bionic) Python2.3 - Python 2.6, Python 3.1 - Python 3.5, Python3.7 - Python3.11
- Ubuntu 20.04 (focal) Python3.5 - Python3.7, Python3.9 - Python3.11
- Ubuntu 22.04 (jammy) Python3.7 - Python3.9, Python3.11
- Note: Python2.7 (all), Python 3.6 (bionic), Python 3.8 (focal), Python 3.10 (jammy) are not provided by deadsnakes as upstream ubuntu provides those packages.

Why some packages aren't built:
- Note: for focal, older python versions require libssl<1.1 so they are not currently built
- Note: for jammy, older python versions requre libssl<3 so they are not currently built
- If you need these, reach out to asottile to set up a private ppa

The packages may also work on other versions of Ubuntu or Debian, but that is not tested or supported.

Packages
========

The packages provided here are loosely based on the debian upstream packages with some modifications to make them more usable as non-default pythons and on ubuntu.  As such, the packages follow debian's patterns and often do not include a full python distribution with just `apt install python#.#`.  Here is a list of packages that may be useful along with the default install:

- `python#.#-dev`: includes development headers for building C extensions
- `python#.#-venv`: provides the standard library `venv` module
- `python#.#-distutils`: provides the standard library `distutils` module
- `python#.#-lib2to3`: provides the `2to3-#.#` utility as well as the standard library `lib2to3` module
- `python#.#-gdbm`: provides the standard library `dbm.gnu` module
- `python#.#-tk`: provides the standard library `tkinter` module

Third-Party Python Modules
==========================

Python modules in the official Ubuntu repositories are packaged to work with the Python interpreters from the official repositories. Accordingly, they generally won't work with the Python interpreters from this PPA. As an exception, pure-Python modules for Python 3 will work, but any compiled extension modules won't.

To install 3rd-party Python modules, you should use the common Python packaging tools.  For an introduction into the Python packaging ecosystem and its tools, refer to the Python Packaging User Guide:
https://packaging.python.org/installing/

Sources
=======
The package sources are available at:
https://github.com/deadsnakes/

Nightly Builds
==============

For nightly builds, see ppa:deadsnakes/nightly https://launchpad.net/~deadsnakes/+archive/ubuntu/nightly
 More info: https://launchpad.net/~deadsnakes/+archive/ubuntu/ppa
Press Enter to continue or Ctrl+C to cancel

Executing: /tmp/tmp.1DA53clwH1/gpg.1.sh --keyserver
hkp://keyserver.ubuntu.com:80
--recv-keys
6A755776
gpg: requesting key 6A755776 from hkp server keyserver.ubuntu.com
gpg: key 6A755776: public key "Launchpad PPA for deadsnakes" imported
gpg: Total number processed: 1
gpg:               imported: 1  (RSA: 1)

這台的 Linux Mint 是 v18, 所以看來可以安裝 Python3.11. 


4. 用 apt install 指令安裝新版 Python 3 :

安裝 Python3.11 居然說找不到此套件 : 

tony1966@tony1966-AOD255 ~ $ sudo apt install python3.11  
Reading package lists... Done
Building dependency tree       
Reading state information... Done
E: Unable to locate package python3.11 
E: Couldn't find any package by glob 'python3.11'
E: Couldn't find any package by regex 'python3.11'

我又重新更新套件清單 : 

tony1966@tony1966-AOD255 ~ $ sudo apt update   
Get:2 http://ppa.launchpad.net/deadsnakes/ppa/ubuntu xenial InRelease [18.1 kB]                                              
Ign:3 http://packages.linuxmint.com serena InRelease                                                                         
Hit:4 http://archive.ubuntu.com/ubuntu xenial InRelease                                                                      
Get:5 http://archive.ubuntu.com/ubuntu xenial-updates InRelease [99.8 kB]                                                    
Get:6 http://archive.ubuntu.com/ubuntu xenial-backports InRelease [97.4 kB]                                                  
Get:7 http://security.ubuntu.com/ubuntu xenial-security InRelease [99.8 kB]                                                  
Hit:8 http://archive.canonical.com/ubuntu xenial InRelease                                                                   
Hit:9 http://packages.linuxmint.com serena Release                                                                           
Hit:1 https://deb.opera.com/opera stable InRelease                                                                           
Fetched 315 kB in 10s (29.5 kB/s)                                                                                            
Reading package lists... Done
Building dependency tree       
Reading state information... Done
4 packages can be upgraded. Run 'apt list --upgradable' to see them.

再次安裝 python3.11 仍然找不到套件 : 

tony1966@tony1966-AOD255 ~ $ sudo apt install python3.11  
Reading package lists... Done
Building dependency tree        
Reading state information... Done
E: Unable to locate package python3.11
E: Couldn't find any package by glob 'python3.11'
E: Couldn't find any package by regex 'python3.11'

退而求其次改安裝 python3.10 還是找不到 : 

tony1966@tony1966-AOD255 ~ $ sudo apt install python3.10  
Reading package lists... Done
Building dependency tree       
Reading state information... Done
E: Unable to locate package python3.10
E: Couldn't find any package by glob 'python3.10'
E: Couldn't find any package by regex 'python3.10'

再次降到 python3.9 有找到且順利安裝 : 

tony1966@tony1966-AOD255 ~ $ sudo apt install python3.9  
Reading package lists... Done
Building dependency tree        
Reading state information... Done
Note, selecting 'postgresql-plpython3-9.5' for regex 'python3.9'
The following additional packages will be installed:
  libpq5 postgresql-9.5 postgresql-client-9.5 postgresql-client-common postgresql-common
Suggested packages:
  locales-all postgresql-doc-9.5
Recommended packages:
  postgresql-contrib-9.5 sysstat
The following NEW packages will be installed:
  libpq5 postgresql-9.5 postgresql-client-9.5 postgresql-client-common postgresql-common postgresql-plpython3-9.5
0 upgraded, 6 newly installed, 0 to remove and 4 not upgraded.
Need to get 4199 kB of archives.
After this operation, 16.7 MB of additional disk space will be used.
Do you want to continue? [Y/n] y   
Get:1 http://archive.ubuntu.com/ubuntu xenial-updates/main amd64 libpq5 amd64 9.5.25-0ubuntu0.16.04.1 [79.2 kB]
Get:2 http://archive.ubuntu.com/ubuntu xenial-updates/main amd64 postgresql-client-common all 173ubuntu0.3 [28.4 kB]
Get:3 http://archive.ubuntu.com/ubuntu xenial-updates/main amd64 postgresql-client-9.5 amd64 9.5.25-0ubuntu0.16.04.1 [878 kB]
Get:4 http://archive.ubuntu.com/ubuntu xenial-updates/main amd64 postgresql-common all 173ubuntu0.3 [154 kB]                 
Get:5 http://archive.ubuntu.com/ubuntu xenial-updates/main amd64 postgresql-9.5 amd64 9.5.25-0ubuntu0.16.04.1 [3018 kB]      
Get:6 http://archive.ubuntu.com/ubuntu xenial-updates/universe amd64 postgresql-plpython3-9.5 amd64 9.5.25-0ubuntu0.16.04.1 [40.6 kB]
Fetched 4199 kB in 7s (567 kB/s)                                                                                             
Preconfiguring packages ...
Selecting previously unselected package libpq5:amd64.
(Reading database ... 226626 files and directories currently installed.)
Preparing to unpack .../libpq5_9.5.25-0ubuntu0.16.04.1_amd64.deb ...
Unpacking libpq5:amd64 (9.5.25-0ubuntu0.16.04.1) ...
Selecting previously unselected package postgresql-client-common.
Preparing to unpack .../postgresql-client-common_173ubuntu0.3_all.deb ...
Unpacking postgresql-client-common (173ubuntu0.3) ...
Selecting previously unselected package postgresql-client-9.5.
Preparing to unpack .../postgresql-client-9.5_9.5.25-0ubuntu0.16.04.1_amd64.deb ...
Unpacking postgresql-client-9.5 (9.5.25-0ubuntu0.16.04.1) ...
Selecting previously unselected package postgresql-common.
Preparing to unpack .../postgresql-common_173ubuntu0.3_all.deb ...
Adding 'diversion of /usr/bin/pg_config to /usr/bin/pg_config.libpq-dev by postgresql-common'
Unpacking postgresql-common (173ubuntu0.3) ...
Selecting previously unselected package postgresql-9.5.
Preparing to unpack .../postgresql-9.5_9.5.25-0ubuntu0.16.04.1_amd64.deb ...
Unpacking postgresql-9.5 (9.5.25-0ubuntu0.16.04.1) ...
Selecting previously unselected package postgresql-plpython3-9.5.
Preparing to unpack .../postgresql-plpython3-9.5_9.5.25-0ubuntu0.16.04.1_amd64.deb ...
Unpacking postgresql-plpython3-9.5 (9.5.25-0ubuntu0.16.04.1) ...
Processing triggers for libc-bin (2.23-0ubuntu11.3) ...
Processing triggers for man-db (2.7.5-1) ...
Processing triggers for ureadahead (0.100.0-19.1) ...
ureadahead will be reprofiled on next reboot
Processing triggers for systemd (229-4ubuntu21.31) ...
Setting up libpq5:amd64 (9.5.25-0ubuntu0.16.04.1) ...
Setting up postgresql-client-common (173ubuntu0.3) ...
Setting up postgresql-client-9.5 (9.5.25-0ubuntu0.16.04.1) ...
update-alternatives: using /usr/share/postgresql/9.5/man/man1/psql.1.gz to provide /usr/share/man/man1/psql.1.gz (psql.1.gz) in auto mode
Setting up postgresql-common (173ubuntu0.3) ...
supported-versions: WARNING! Unknown distribution: linuxmint
ubuntu found in ID_LIKE, treating as Ubuntu
supported-versions: WARNING: Unknown Ubuntu release: 18.1
Adding user postgres to group ssl-cert

Creating config file /etc/postgresql-common/createcluster.conf with new version

Creating config file /etc/logrotate.d/postgresql-common with new version
Building PostgreSQL dictionaries from installed myspell/hunspell packages...
  en_us
Removing obsolete dictionary files:
Setting up postgresql-9.5 (9.5.25-0ubuntu0.16.04.1) ...
Creating new cluster 9.5/main ...
  config /etc/postgresql/9.5/main
  data   /var/lib/postgresql/9.5/main
  locale en_US.UTF-8
  socket /var/run/postgresql
  port   5432
update-alternatives: using /usr/share/postgresql/9.5/man/man1/postmaster.1.gz to provide /usr/share/man/man1/postmaster.1.gz (postmaster.1.gz) in auto mode
Setting up postgresql-plpython3-9.5 (9.5.25-0ubuntu0.16.04.1) ...
Processing triggers for libc-bin (2.23-0ubuntu11.3) ...
Processing triggers for ureadahead (0.100.0-19.1) ...
Processing triggers for systemd (229-4ubuntu21.31) ...

但是安裝完畢輸入 python3.9 卻找不到此指令 : 

tony1966@tony1966-AOD255 ~ $ python3.9  
No command 'python3.9' found, did you mean:
 Command 'python3.5' from package 'python3.5-minimal' (main)
python3.9: command not found

用 ls 檢視 /usr/bin 底下的所有安裝的 Python 居然找不到 3.9 版 : 

tony1966@tony1966-AOD255 ~ $ ls -ls /usr/bin/python* 
   0 lrwxrwxrwx 1 root root       9 Nov 24  2017 /usr/bin/python -> python2.7
   0 lrwxrwxrwx 1 root root       9 Nov 24  2017 /usr/bin/python2 -> python2.7
3412 -rwxr-xr-x 1 root root 3492624 Mar  2  2021 /usr/bin/python2.7
   0 lrwxrwxrwx 1 root root       9 Jun  6  2017 /usr/bin/python3 -> python3.5
4352 -rwxr-xr-x 2 root root 4456208 Jan 27  2021 /usr/bin/python3.5
4352 -rwxr-xr-x 2 root root 4456208 Jan 27  2021 /usr/bin/python3.5m
   0 lrwxrwxrwx 1 root root      10 Jun  6  2017 /usr/bin/python3m -> python3.5m

重新開機還是沒有, 我的 Linux 知識太淺薄, 不知問題出在哪裡, 明天有空再研究. 參考 : 



2023-04-20 補充 : 

仔細看上面的安裝過程才發現原來安裝的並非 Python3.9, 而是 Postgre 與 Python 相關的套件. 基本上除非這台的 Linux Mint 升版, 否則應該無法升到 3.8 版以上了. 

2 則留言 :

路人乙 提到...

Ubuntu衍生的系統可以試試deadsnakes repository
參考
Installing multiple alternative versions of Python on Ubuntu 20.04
https://towardsdatascience.com/-237be5177474

小狐狸事務所 提到...

感謝您