【python初级】 Ubuntu18.04上安装python3、pip3

2021/11/5 7:09:58

本文主要是介绍【python初级】 Ubuntu18.04上安装python3、pip3,对大家解决编程问题具有一定的参考价值,需要的程序猿们随着小编来一起学习吧!

【python初级】 Ubuntu18.04上安装python3、pip3

  • 1、背景
  • 2、安装python3
  • 3、安装pip3

1、背景

最近在使用docker部署。
通过docker镜像创建的容器中没有python3。

Ubuntu18.04系统环境:

root@7a8faaaebdbb:/# cat /proc/version
Linux version 5.4.0-87-generic (buildd@lgw01-amd64-059) (gcc version 7.5.0 (Ubuntu 7.5.0-3ubuntu1~18.04)) #98~18.04.1-Ubuntu SMP Wed Sep 22 10:45:04 UTC 2021
root@7a8faaaebdbb:/# uname -r
5.4.0-87-generic
root@7a8faaaebdbb:/#

2、安装python3

安装命令:apt install python3.6

安装之前执行apt update,更新可用软件包列表。避免出现找不到安装包的报错。

安装细节如下:

root@7a8faaaebdbb:/# apt install python3.6  
Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following additional packages will be installed:
  file libexpat1 libmagic-mgc libmagic1 libmpdec2 libpython3.6-minimal libpython3.6-stdlib mime-support python3.6-minimal
Suggested packages:
  python3.6-venv python3.6-doc binfmt-support
The following NEW packages will be installed:
  file libexpat1 libmagic-mgc libmagic1 libmpdec2 libpython3.6-minimal libpython3.6-stdlib mime-support python3.6 python3.6-minimal
0 upgraded, 10 newly installed, 0 to remove and 15 not upgraded.
Need to get 4528 kB of archives.
After this operation, 27.5 MB of additional disk space will be used.
Do you want to continue? [Y/n] Y
Get:1 http://archive.ubuntu.com/ubuntu bionic-updates/main amd64 libpython3.6-minimal amd64 3.6.9-1~18.04ubuntu1.4 [534 kB]
Get:2 http://archive.ubuntu.com/ubuntu bionic-updates/main amd64 libexpat1 amd64 2.2.5-3ubuntu0.2 [80.5 kB]
Get:3 http://archive.ubuntu.com/ubuntu bionic-updates/main amd64 python3.6-minimal amd64 3.6.9-1~18.04ubuntu1.4 [1610 kB]
Get:4 http://archive.ubuntu.com/ubuntu bionic-updates/main amd64 libmagic-mgc amd64 1:5.32-2ubuntu0.4 [184 kB]
Get:5 http://archive.ubuntu.com/ubuntu bionic-updates/main amd64 libmagic1 amd64 1:5.32-2ubuntu0.4 [68.6 kB]
Get:6 http://archive.ubuntu.com/ubuntu bionic-updates/main amd64 file amd64 1:5.32-2ubuntu0.4 [22.1 kB]
Get:7 http://archive.ubuntu.com/ubuntu bionic/main amd64 libmpdec2 amd64 2.4.2-1ubuntu1 [84.1 kB]
Get:8 http://archive.ubuntu.com/ubuntu bionic/main amd64 mime-support all 3.60ubuntu1 [30.1 kB]
Get:9 http://archive.ubuntu.com/ubuntu bionic-updates/main amd64 libpython3.6-stdlib amd64 3.6.9-1~18.04ubuntu1.4 [1712 kB]
Get:10 http://archive.ubuntu.com/ubuntu bionic-updates/main amd64 python3.6 amd64 3.6.9-1~18.04ubuntu1.4 [203 kB]
Fetched 4528 kB in 3s (1349 kB/s)    
debconf: delaying package configuration, since apt-utils is not installed
Selecting previously unselected package libpython3.6-minimal:amd64.
(Reading database ... 12893 files and directories currently installed.)
Preparing to unpack .../0-libpython3.6-minimal_3.6.9-1~18.04ubuntu1.4_amd64.deb ...

Progress: [  0%] [...........................................................................................................................................................] 
Unpacking libpython3.6-minimal:amd64 (3.6.9-1~18.04ubuntu1.4) ...............................................................................................................] 

Progress: [  4%] [######.....................................................................................................................................................] 
Selecting previously unselected package libexpat1:amd64......................................................................................................................] 
Preparing to unpack .../1-libexpat1_2.2.5-3ubuntu0.2_amd64.deb ...

Unpacking libexpat1:amd64 (2.2.5-3ubuntu0.2) ................................................................................................................................] 

Progress: [ 10%] [###############............................................................................................................................................] 
Selecting previously unselected package python3.6-minimal....................................................................................................................] 
Preparing to unpack .../2-python3.6-minimal_3.6.9-1~18.04ubuntu1.4_amd64.deb ...

Unpacking python3.6-minimal (3.6.9-1~18.04ubuntu1.4) ........................................................................................................................] 

Progress: [ 16%] [########################...................................................................................................................................] 
Selecting previously unselected package libmagic-mgc.........................................................................................................................] 
Preparing to unpack .../3-libmagic-mgc_1%3a5.32-2ubuntu0.4_amd64.deb ...

Unpacking libmagic-mgc (1:5.32-2ubuntu0.4) ...##.............................................................................................................................] 

Progress: [ 22%] [#################################..........................................................................................................................] 
Selecting previously unselected package libmagic1:amd64......................................................................................................................] 
Preparing to unpack .../4-libmagic1_1%3a5.32-2ubuntu0.4_amd64.deb ...

Unpacking libmagic1:amd64 (1:5.32-2ubuntu0.4) ...########....................................................................................................................] 

Progress: [ 27%] [##########################################.................................................................................................................] 
Selecting previously unselected package file.##################..............................................................................................................] 
Preparing to unpack .../5-file_1%3a5.32-2ubuntu0.4_amd64.deb ...

Unpacking file (1:5.32-2ubuntu0.4) ...############################...........................................................................................................] 

Progress: [ 33%] [###################################################........................................................................................................] 
Selecting previously unselected package libmpdec2:amd64.################.....................................................................................................] 
Preparing to unpack .../6-libmpdec2_2.4.2-1ubuntu1_amd64.deb ...

Unpacking libmpdec2:amd64 (2.4.2-1ubuntu1) ...#############################..................................................................................................] 

Progress: [ 39%] [############################################################...............................................................................................] 
Selecting previously unselected package mime-support.############################............................................................................................] 
Preparing to unpack .../7-mime-support_3.60ubuntu1_all.deb ...

Unpacking mime-support (3.60ubuntu1) ...############################################.........................................................................................] 

Progress: [ 45%] [#####################################################################......................................................................................] 
Selecting previously unselected package libpython3.6-stdlib:amd64.########################...................................................................................] 
Preparing to unpack .../8-libpython3.6-stdlib_3.6.9-1~18.04ubuntu1.4_amd64.deb ...

Unpacking libpython3.6-stdlib:amd64 (3.6.9-1~18.04ubuntu1.4) ...#############################................................................................................] 

Progress: [ 51%] [###############################################################################............................................................................] 
Selecting previously unselected package python3.6.##################################################.........................................................................] 
Preparing to unpack .../9-python3.6_3.6.9-1~18.04ubuntu1.4_amd64.deb ...

Unpacking python3.6 (3.6.9-1~18.04ubuntu1.4) ...#######################################################......................................................................] 

Progress: [ 57%] [########################################################################################...................................................................] 
Setting up libexpat1:amd64 (2.2.5-3ubuntu0.2) ...############################################################................................................................] 

Progress: [ 61%] [##############################################################################################.............................................................] 
Setting up mime-support (3.60ubuntu1) ...##########################################################################..........................................................] 

Progress: [ 65%] [####################################################################################################.......................................................] 
Setting up libmagic-mgc (1:5.32-2ubuntu0.4) ...##########################################################################....................................................] 

Progress: [ 69%] [##########################################################################################################.................................................] 
Setting up libmagic1:amd64 (1:5.32-2ubuntu0.4) ...#############################################################################..............................................] 

Progress: [ 73%] [################################################################################################################...........................................] 
Setting up libpython3.6-minimal:amd64 (3.6.9-1~18.04ubuntu1.4) ...###################################################################........................................] 

Progress: [ 76%] [######################################################################################################################.....................................] 
Setting up libmpdec2:amd64 (2.4.2-1ubuntu1) ...############################################################################################..................................] 

Progress: [ 80%] [############################################################################################################################...............................] 
Setting up libpython3.6-stdlib:amd64 (3.6.9-1~18.04ubuntu1.4) ...################################################################################............................] 

Progress: [ 84%] [##################################################################################################################################.........................] 
Setting up python3.6-minimal (3.6.9-1~18.04ubuntu1.4) ...##############################################################################################......................] 

Progress: [ 88%] [########################################################################################################################################...................] 
Setting up file (1:5.32-2ubuntu0.4) ...######################################################################################################################................] 

Progress: [ 92%] [##############################################################################################################################################.............] 
Setting up python3.6 (3.6.9-1~18.04ubuntu1.4) ...##################################################################################################################..........] 

Progress: [ 96%] [####################################################################################################################################################.......] 
Processing triggers for libc-bin (2.27-3ubuntu1.4) ...###################################################################################################################....] 
root@7a8faaaebdbb:/# 

python3安装验证
如下安装成功

root@7a8faaaebdbb:/# python
bash: python: command not found
root@7a8faaaebdbb:/# python2
bash: python2: command not found
root@7a8faaaebdbb:/# python3
bash: python3: command not found
root@7a8faaaebdbb:/# python3.6
Python 3.6.9 (default, Jan 26 2021, 15:33:00) 
[GCC 8.4.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> 

3、安装pip3

安装命令:apt install python3-pip

安装细节:

root@7a8faaaebdbb:/# apt install python3-pip
Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following additional packages will be installed:
  dbus dh-python gir1.2-glib-2.0 libapparmor1 libdbus-1-3 libexpat1-dev libgirepository-1.0-1 libglib2.0-0 libglib2.0-data libicu60 libpython3-dev libpython3-stdlib
  libpython3.6 libpython3.6-dev libxml2 python-pip-whl python3 python3-asn1crypto python3-cffi-backend python3-crypto python3-cryptography python3-dbus python3-dev
  python3-distutils python3-gi python3-idna python3-keyring python3-keyrings.alt python3-lib2to3 python3-minimal python3-pkg-resources python3-secretstorage python3-setuptools
  python3-six python3-wheel python3-xdg python3.6-dev shared-mime-info xdg-user-dirs
Suggested packages:
  default-dbus-session-bus | dbus-session-bus python3-doc python3-tk python3-venv python-crypto-doc python-cryptography-doc python3-cryptography-vectors python-dbus-doc
  python3-dbus-dbg gnome-keyring libkf5wallet-bin gir1.2-gnomekeyring-1.0 python-secretstorage-doc python-setuptools-doc
The following NEW packages will be installed:
  dbus dh-python gir1.2-glib-2.0 libapparmor1 libdbus-1-3 libexpat1-dev libgirepository-1.0-1 libglib2.0-0 libglib2.0-data libicu60 libpython3-dev libpython3-stdlib
  libpython3.6 libpython3.6-dev libxml2 python-pip-whl python3 python3-asn1crypto python3-cffi-backend python3-crypto python3-cryptography python3-dbus python3-dev
  python3-distutils python3-gi python3-idna python3-keyring python3-keyrings.alt python3-lib2to3 python3-minimal python3-pip python3-pkg-resources python3-secretstorage
  python3-setuptools python3-six python3-wheel python3-xdg python3.6-dev shared-mime-info xdg-user-dirs
0 upgraded, 40 newly installed, 0 to remove and 15 not upgraded.
Need to get 61.4 MB of archives.
After this operation, 139 MB of additional disk space will be used.
Do you want to continue? [Y/n] y^HY^H^H
Get:1 http://archive.ubuntu.com/ubuntu bionic-updates/main amd64 python3-minimal amd64 3.6.7-1~18.04 [23.7 kB]
Get:2 http://archive.ubuntu.com/ubuntu bionic-updates/main amd64 libpython3-stdlib amd64 3.6.7-1~18.04 [7240 B]
Get:3 http://archive.ubuntu.com/ubuntu bionic-updates/main amd64 python3 amd64 3.6.7-1~18.04 [47.2 kB]
Get:4 http://archive.ubuntu.com/ubuntu bionic-updates/main amd64 libapparmor1 amd64 2.12-4ubuntu5.1 [31.3 kB]
Get:5 http://archive.ubuntu.com/ubuntu bionic-updates/main amd64 libdbus-1-3 amd64 1.12.2-1ubuntu1.2 [175 kB]
Get:6 http://archive.ubuntu.com/ubuntu bionic-updates/main amd64 dbus amd64 1.12.2-1ubuntu1.2 [150 kB]
Get:7 http://archive.ubuntu.com/ubuntu bionic-updates/main amd64 libglib2.0-0 amd64 2.56.4-0ubuntu0.18.04.8 [1171 kB]
Get:8 http://archive.ubuntu.com/ubuntu bionic/main amd64 libgirepository-1.0-1 amd64 1.56.1-1 [82.0 kB]
Get:9 http://archive.ubuntu.com/ubuntu bionic/main amd64 gir1.2-glib-2.0 amd64 1.56.1-1 [131 kB]
Get:10 http://archive.ubuntu.com/ubuntu bionic-updates/main amd64 libglib2.0-data all 2.56.4-0ubuntu0.18.04.8 [4716 B]
Get:11 http://archive.ubuntu.com/ubuntu bionic-updates/main amd64 libicu60 amd64 60.2-3ubuntu3.1 [8054 kB]
Get:12 http://archive.ubuntu.com/ubuntu bionic-updates/main amd64 libxml2 amd64 2.9.4+dfsg1-6.1ubuntu1.4 [664 kB]
Get:13 http://archive.ubuntu.com/ubuntu bionic/main amd64 python3-dbus amd64 1.2.6-1 [89.9 kB]
Get:14 http://archive.ubuntu.com/ubuntu bionic-updates/main amd64 python3-gi amd64 3.26.1-2ubuntu1 [153 kB]
Get:15 http://archive.ubuntu.com/ubuntu bionic/main amd64 shared-mime-info amd64 1.9-2 [426 kB]
Get:16 http://archive.ubuntu.com/ubuntu bionic/main amd64 xdg-user-dirs amd64 0.17-1ubuntu1 [48.0 kB]
Get:17 http://archive.ubuntu.com/ubuntu bionic-updates/main amd64 python3-lib2to3 all 3.6.9-1~18.04 [77.4 kB]
Get:18 http://archive.ubuntu.com/ubuntu bionic-updates/main amd64 python3-distutils all 3.6.9-1~18.04 [144 kB]
Get:19 http://archive.ubuntu.com/ubuntu bionic/main amd64 dh-python all 3.20180325ubuntu2 [89.2 kB]
Get:20 http://archive.ubuntu.com/ubuntu bionic-updates/main amd64 libexpat1-dev amd64 2.2.5-3ubuntu0.2 [122 kB]
Get:21 http://archive.ubuntu.com/ubuntu bionic-updates/main amd64 libpython3.6 amd64 3.6.9-1~18.04ubuntu1.4 [1414 kB]
Get:22 http://archive.ubuntu.com/ubuntu bionic-updates/main amd64 libpython3.6-dev amd64 3.6.9-1~18.04ubuntu1.4 [44.9 MB]
Get:23 http://archive.ubuntu.com/ubuntu bionic-updates/main amd64 libpython3-dev amd64 3.6.7-1~18.04 [7328 B]                                                                   
Get:24 http://archive.ubuntu.com/ubuntu bionic-updates/universe amd64 python-pip-whl all 9.0.1-2.3~ubuntu1.18.04.5 [1653 kB]                                                    
Get:25 http://archive.ubuntu.com/ubuntu bionic/main amd64 python3-asn1crypto all 0.24.0-1 [72.8 kB]                                                                             
Get:26 http://archive.ubuntu.com/ubuntu bionic/main amd64 python3-cffi-backend amd64 1.11.5-1 [64.6 kB]                                                                         
Get:27 http://archive.ubuntu.com/ubuntu bionic/main amd64 python3-crypto amd64 2.6.1-8ubuntu2 [244 kB]                                                                          
Get:28 http://archive.ubuntu.com/ubuntu bionic/main amd64 python3-idna all 2.6-1 [32.5 kB]                                                                                      
Get:29 http://archive.ubuntu.com/ubuntu bionic/main amd64 python3-six all 1.11.0-2 [11.4 kB]                                                                                    
Get:30 http://archive.ubuntu.com/ubuntu bionic-updates/main amd64 python3-cryptography amd64 2.1.4-1ubuntu1.4 [220 kB]                                                          
Get:31 http://archive.ubuntu.com/ubuntu bionic-updates/main amd64 python3.6-dev amd64 3.6.9-1~18.04ubuntu1.4 [508 kB]                                                           
Get:32 http://archive.ubuntu.com/ubuntu bionic-updates/main amd64 python3-dev amd64 3.6.7-1~18.04 [1288 B]                                                                      
Get:33 http://archive.ubuntu.com/ubuntu bionic/main amd64 python3-secretstorage all 2.3.1-2 [12.1 kB]                                                                           
Get:34 http://archive.ubuntu.com/ubuntu bionic/main amd64 python3-keyring all 10.6.0-1 [26.7 kB]                                                                                
Get:35 http://archive.ubuntu.com/ubuntu bionic/main amd64 python3-keyrings.alt all 3.0-1 [16.6 kB]                                                                              
Get:36 http://archive.ubuntu.com/ubuntu bionic-updates/universe amd64 python3-pip all 9.0.1-2.3~ubuntu1.18.04.5 [114 kB]                                                        
Get:37 http://archive.ubuntu.com/ubuntu bionic/main amd64 python3-pkg-resources all 39.0.1-2 [98.8 kB]                                                                          
Get:38 http://archive.ubuntu.com/ubuntu bionic/main amd64 python3-setuptools all 39.0.1-2 [248 kB]                                                                              
Get:39 http://archive.ubuntu.com/ubuntu bionic/universe amd64 python3-wheel all 0.30.0-0.2 [36.5 kB]                                                                            
Get:40 http://archive.ubuntu.com/ubuntu bionic-updates/main amd64 python3-xdg all 0.25-4ubuntu1.1 [31.3 kB]                                                                     
Fetched 61.4 MB in 17s (3680 kB/s)                                                                                                                                              
debconf: delaying package configuration, since apt-utils is not installed
Selecting previously unselected package python3-minimal.
(Reading database ... 13575 files and directories currently installed.)
Preparing to unpack .../python3-minimal_3.6.7-1~18.04_amd64.deb ...

Unpacking python3-minimal (3.6.7-1~18.04) ...................................................................................................................................] 

Selecting previously unselected package libpython3-stdlib:amd64..............................................................................................................] 
Preparing to unpack .../libpython3-stdlib_3.6.7-1~18.04_amd64.deb ...
Unpacking libpython3-stdlib:amd64 (3.6.7-1~18.04) ...

Setting up python3-minimal (3.6.7-1~18.04) ..................................................................................................................................] 

Selecting previously unselected package python3..............................................................................................................................] 
(Reading database ... 13602 files and directories currently installed.)
Preparing to unpack .../00-python3_3.6.7-1~18.04_amd64.deb ...

Unpacking python3 (3.6.7-1~18.04) ...........................................................................................................................................] 

Selecting previously unselected package libapparmor1:amd64...................................................................................................................] 
Preparing to unpack .../01-libapparmor1_2.12-4ubuntu5.1_amd64.deb ...
Unpacking libapparmor1:amd64 (2.12-4ubuntu5.1) ...

Selecting previously unselected package libdbus-1-3:amd64....................................................................................................................] 
Preparing to unpack .../02-libdbus-1-3_1.12.2-1ubuntu1.2_amd64.deb ...

Unpacking libdbus-1-3:amd64 (1.12.2-1ubuntu1.2) .............................................................................................................................] 

Selecting previously unselected package dbus.................................................................................................................................] 
Preparing to unpack .../03-dbus_1.12.2-1ubuntu1.2_amd64.deb ...
Unpacking dbus (1.12.2-1ubuntu1.2) ...

Selecting previously unselected package libglib2.0-0:amd64...................................................................................................................] 
Preparing to unpack .../04-libglib2.0-0_2.56.4-0ubuntu0.18.04.8_amd64.deb ...

Unpacking libglib2.0-0:amd64 (2.56.4-0ubuntu0.18.04.8) ......................................................................................................................] 

Selecting previously unselected package libgirepository-1.0-1:amd64..........................................................................................................] 
Preparing to unpack .../05-libgirepository-1.0-1_1.56.1-1_amd64.deb ...
Unpacking libgirepository-1.0-1:amd64 (1.56.1-1) ...

Selecting previously unselected package gir1.2-glib-2.0:amd64................................................................................................................] 
Preparing to unpack .../06-gir1.2-glib-2.0_1.56.1-1_amd64.deb ...

Unpacking gir1.2-glib-2.0:amd64 (1.56.1-1) ..................................................................................................................................] 

Selecting previously unselected package libglib2.0-data......................................................................................................................] 
Preparing to unpack .../07-libglib2.0-data_2.56.4-0ubuntu0.18.04.8_all.deb ...
Unpacking libglib2.0-data (2.56.4-0ubuntu0.18.04.8) ...

Selecting previously unselected package libicu60:amd64.......................................................................................................................] 
Preparing to unpack .../08-libicu60_60.2-3ubuntu3.1_amd64.deb ...

Unpacking libicu60:amd64 (60.2-3ubuntu3.1) ..................................................................................................................................] 

Selecting previously unselected package libxml2:amd64........................................................................................................................] 
Preparing to unpack .../09-libxml2_2.9.4+dfsg1-6.1ubuntu1.4_amd64.deb ...
Unpacking libxml2:amd64 (2.9.4+dfsg1-6.1ubuntu1.4) ...

Selecting previously unselected package python3-dbus.........................................................................................................................] 
Preparing to unpack .../10-python3-dbus_1.2.6-1_amd64.deb ...

Unpacking python3-dbus (1.2.6-1) ...############.............................................................................................................................] 

Selecting previously unselected package python3-gi...........................................................................................................................] 
Preparing to unpack .../11-python3-gi_3.26.1-2ubuntu1_amd64.deb ...
Unpacking python3-gi (3.26.1-2ubuntu1) ...

Selecting previously unselected package shared-mime-info.....................................................................................................................] 
Preparing to unpack .../12-shared-mime-info_1.9-2_amd64.deb ...

Unpacking shared-mime-info (1.9-2) ...##############.........................................................................................................................] 

Selecting previously unselected package xdg-user-dirs........................................................................................................................] 
Preparing to unpack .../13-xdg-user-dirs_0.17-1ubuntu1_amd64.deb ...
Unpacking xdg-user-dirs (0.17-1ubuntu1) ...

Selecting previously unselected package python3-lib2to3......................................................................................................................] 
Preparing to unpack .../14-python3-lib2to3_3.6.9-1~18.04_all.deb ...

Unpacking python3-lib2to3 (3.6.9-1~18.04) ...############....................................................................................................................] 

Selecting previously unselected package python3-distutils....................................................................................................................] 
Preparing to unpack .../15-python3-distutils_3.6.9-1~18.04_all.deb ...
Unpacking python3-distutils (3.6.9-1~18.04) ...

Selecting previously unselected package dh-python.##########.................................................................................................................] 
Preparing to unpack .../16-dh-python_3.20180325ubuntu2_all.deb ...

Unpacking dh-python (3.20180325ubuntu2) ...##################................................................................................................................] 

Selecting previously unselected package libexpat1-dev:amd64.###..............................................................................................................] 
Preparing to unpack .../17-libexpat1-dev_2.2.5-3ubuntu0.2_amd64.deb ...
Unpacking libexpat1-dev:amd64 (2.2.5-3ubuntu0.2) ...

Selecting previously unselected package libpython3.6:amd64.######............................................................................................................] 
Preparing to unpack .../18-libpython3.6_3.6.9-1~18.04ubuntu1.4_amd64.deb ...

Unpacking libpython3.6:amd64 (3.6.9-1~18.04ubuntu1.4) ...#########...........................................................................................................] 

Selecting previously unselected package libpython3.6-dev:amd64.#####.........................................................................................................] 
Preparing to unpack .../19-libpython3.6-dev_3.6.9-1~18.04ubuntu1.4_amd64.deb ...
Unpacking libpython3.6-dev:amd64 (3.6.9-1~18.04ubuntu1.4) ...

Selecting previously unselected package libpython3-dev:amd64.########........................................................................................................] 
Preparing to unpack .../20-libpython3-dev_3.6.7-1~18.04_amd64.deb ...

Unpacking libpython3-dev:amd64 (3.6.7-1~18.04) ...#####################......................................................................................................] 

Selecting previously unselected package python-pip-whl.#################.....................................................................................................] 
Preparing to unpack .../21-python-pip-whl_9.0.1-2.3~ubuntu1.18.04.5_all.deb ...
Unpacking python-pip-whl (9.0.1-2.3~ubuntu1.18.04.5) ...

Selecting previously unselected package python3-asn1crypto.###############...................................................................................................] 
Preparing to unpack .../22-python3-asn1crypto_0.24.0-1_all.deb ...

Unpacking python3-asn1crypto (0.24.0-1) ...################################..................................................................................................] 

Selecting previously unselected package python3-cffi-backend.################................................................................................................] 
Preparing to unpack .../23-python3-cffi-backend_1.11.5-1_amd64.deb ...
Unpacking python3-cffi-backend (1.11.5-1) ...

Selecting previously unselected package python3-crypto.#######################...............................................................................................] 
Preparing to unpack .../24-python3-crypto_2.6.1-8ubuntu2_amd64.deb ...

Unpacking python3-crypto (2.6.1-8ubuntu2) ...###################################.............................................................................................] 

Selecting previously unselected package python3-idna.#############################...........................................................................................] 
Preparing to unpack .../25-python3-idna_2.6-1_all.deb ...
Unpacking python3-idna (2.6-1) ...

Selecting previously unselected package python3-six.###############################..........................................................................................] 
Preparing to unpack .../26-python3-six_1.11.0-2_all.deb ...

Unpacking python3-six (1.11.0-2) ...#################################################........................................................................................] 

Selecting previously unselected package python3-cryptography.#########################.......................................................................................] 
Preparing to unpack .../27-python3-cryptography_2.1.4-1ubuntu1.4_amd64.deb ...
Unpacking python3-cryptography (2.1.4-1ubuntu1.4) ...

Selecting previously unselected package python3.6-dev.##################################.....................................................................................] 
Preparing to unpack .../28-python3.6-dev_3.6.9-1~18.04ubuntu1.4_amd64.deb ...

Unpacking python3.6-dev (3.6.9-1~18.04ubuntu1.4) ...#####################################....................................................................................] 

Selecting previously unselected package python3-dev.#######################################..................................................................................] 
Preparing to unpack .../29-python3-dev_3.6.7-1~18.04_amd64.deb ...
Unpacking python3-dev (3.6.7-1~18.04) ...

Selecting previously unselected package python3-secretstorage.##############################.................................................................................] 
Preparing to unpack .../30-python3-secretstorage_2.3.1-2_all.deb ...

Unpacking python3-secretstorage (2.3.1-2) ...#################################################...............................................................................] 

Selecting previously unselected package python3-keyring.#######################################..............................................................................] 
Preparing to unpack .../31-python3-keyring_10.6.0-1_all.deb ...
Unpacking python3-keyring (10.6.0-1) ...

Selecting previously unselected package python3-keyrings.alt.####################################............................................................................] 
Preparing to unpack .../32-python3-keyrings.alt_3.0-1_all.deb ...

Unpacking python3-keyrings.alt (3.0-1) ...########################################################...........................................................................] 

Selecting previously unselected package python3-pip.################################################.........................................................................] 
Preparing to unpack .../33-python3-pip_9.0.1-2.3~ubuntu1.18.04.5_all.deb ...
Unpacking python3-pip (9.0.1-2.3~ubuntu1.18.04.5) ...

Selecting previously unselected package python3-pkg-resources.########################################.......................................................................] 
Preparing to unpack .../34-python3-pkg-resources_39.0.1-2_all.deb ...

Unpacking python3-pkg-resources (39.0.1-2) ...#########################################################......................................................................] 

Selecting previously unselected package python3-setuptools.##############################################....................................................................] 
Preparing to unpack .../35-python3-setuptools_39.0.1-2_all.deb ...
Unpacking python3-setuptools (39.0.1-2) ...

Selecting previously unselected package python3-wheel.####################################################...................................................................] 
Preparing to unpack .../36-python3-wheel_0.30.0-0.2_all.deb ...

Unpacking python3-wheel (0.30.0-0.2) ...####################################################################.................................................................] 

Selecting previously unselected package python3-xdg.#########################################################................................................................] 
Preparing to unpack .../37-python3-xdg_0.25-4ubuntu1.1_all.deb ...
Unpacking python3-xdg (0.25-4ubuntu1.1) ...

Setting up libpython3-stdlib:amd64 (3.6.7-1~18.04) ...#########################################################..............................................................] 

Setting up python-pip-whl (9.0.1-2.3~ubuntu1.18.04.5) ...#######################################################.............................................................] 

Setting up libicu60:amd64 (60.2-3ubuntu3.1) ...###################################################################...........................................................] 

Setting up python3 (3.6.7-1~18.04) ...#############################################################################..........................................................] 

running python rtupdate hooks for python3.6...#######################################################################........................................................] 
running python post-rtupdate hooks for python3.6...
Setting up python3-cffi-backend (1.11.5-1) ...

Setting up python3-crypto (2.6.1-8ubuntu2) ...#########################################################################......................................................] 

Setting up libglib2.0-0:amd64 (2.56.4-0ubuntu0.18.04.8) ...#############################################################.....................................................] 

No schema files found: doing nothing.#####################################################################################...................................................] 
Setting up python3-idna (2.6-1) ...

Setting up python3-xdg (0.25-4ubuntu1.1) ...###############################################################################..................................................] 

Setting up python3-six (1.11.0-2) ...########################################################################################................................................] 

Setting up python3-wheel (0.30.0-0.2) ...#####################################################################################...............................................] 

Setting up python3-pkg-resources (39.0.1-2) ...#################################################################################.............................................] 

Setting up libgirepository-1.0-1:amd64 (1.56.1-1) ...############################################################################............................................] 

Setting up libxml2:amd64 (2.9.4+dfsg1-6.1ubuntu1.4) ...############################################################################..........................................] 

Setting up python3-asn1crypto (0.24.0-1) ...########################################################################################.........................................] 

Setting up gir1.2-glib-2.0:amd64 (1.56.1-1) ...#######################################################################################.......................................] 

Setting up libglib2.0-data (2.56.4-0ubuntu0.18.04.8) ...###############################################################################......................................] 

Setting up libapparmor1:amd64 (2.12-4ubuntu5.1) ...######################################################################################....................................] 

Setting up libexpat1-dev:amd64 (2.2.5-3ubuntu0.2) ...######################################################################################..................................] 

Setting up shared-mime-info (1.9-2) ...#####################################################################################################.................................] 

Setting up python3-lib2to3 (3.6.9-1~18.04) ...################################################################################################...............................] 

Setting up xdg-user-dirs (0.17-1ubuntu1) ...###################################################################################################..............................] 

Setting up python3-distutils (3.6.9-1~18.04) ...#################################################################################################............................] 

Setting up libdbus-1-3:amd64 (1.12.2-1ubuntu1.2) ...##############################################################################################...........................] 

Setting up libpython3.6:amd64 (3.6.9-1~18.04ubuntu1.4) ...##########################################################################################.........................] 

Setting up python3-cryptography (2.1.4-1ubuntu1.4) ...###############################################################################################........................] 

Setting up python3-dbus (1.2.6-1) ...##################################################################################################################......................] 

Setting up python3-keyrings.alt (3.0-1) ...#############################################################################################################.....................] 

Setting up python3-gi (3.26.1-2ubuntu1) ...###############################################################################################################...................] 

Setting up libpython3.6-dev:amd64 (3.6.9-1~18.04ubuntu1.4) ...##############################################################################################.................] 

Setting up python3-pip (9.0.1-2.3~ubuntu1.18.04.5) ...#######################################################################################################................] 

Setting up dbus (1.12.2-1ubuntu1.2) ...########################################################################################################################..............] 

Setting up python3-setuptools (39.0.1-2) ...####################################################################################################################.............] 

Setting up python3.6-dev (3.6.9-1~18.04ubuntu1.4) ...#############################################################################################################...........] 

Setting up python3-secretstorage (2.3.1-2) ...#####################################################################################################################..........] 

Setting up dh-python (3.20180325ubuntu2) ...#########################################################################################################################........] 

Setting up libpython3-dev:amd64 (3.6.7-1~18.04) ...###################################################################################################################.......] 

Setting up python3-keyring (10.6.0-1) ...###############################################################################################################################.....] 

Setting up python3-dev (3.6.7-1~18.04) ...###############################################################################################################################....] 

Processing triggers for libc-bin (2.27-3ubuntu1.4) ...#####################################################################################################################..] 

pip3安装验证
如下安装成功.

root@7a8faaaebdbb:/# python
bash: python: command not found
root@7a8faaaebdbb:/# python2
bash: python2: command not found
root@7a8faaaebdbb:/# python3
Python 3.6.9 (default, Jan 26 2021, 15:33:00) 
[GCC 8.4.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> quit()
root@7a8faaaebdbb:/# python3.6
Python 3.6.9 (default, Jan 26 2021, 15:33:00) 
[GCC 8.4.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> quit()
root@7a8faaaebdbb:/# pip
bash: pip: command not found
root@7a8faaaebdbb:/# pip3 list
DEPRECATION: The default format will switch to columns in the future. You can use --format=(legacy|columns) (or define a format=(legacy|columns) in your pip.conf under the [list] section) to disable this warning.
asn1crypto (0.24.0)
cryptography (2.1.4)
idna (2.6)
keyring (10.6.0)
keyrings.alt (3.0)
pip (9.0.1)
pycrypto (2.6.1)
pygobject (3.26.1)
pyxdg (0.25)
SecretStorage (2.3.1)
setuptools (39.0.1)
six (1.11.0)
wheel (0.30.0)
root@7a8faaaebdbb:/#

如上安装了pip3之后,pip3可以使用了。
同时做了python3到python3.6的软链接。



这篇关于【python初级】 Ubuntu18.04上安装python3、pip3的文章就介绍到这儿,希望我们推荐的文章对大家有所帮助,也希望大家多多支持为之网!


扫一扫关注最新编程教程