遵循以下指示:https://docs.docker.com/install/linux/docker-ce/ubuntu/#install-using-the-repository 我正在尝试在Ubuntu 18.04.02 Server Edition中安装Docker Engine。
首次安装的步骤运行正常,但遇到了以下错误消息:
(base) marco@pc:~$ sudo add-apt-repository \
> "deb [arch=amd64] https://download.docker.com/linux/ubuntu \
> $(lsb_release -cs) \
> stable"
Traceback (most recent call last):
File "/usr/bin/add-apt-repository", line 11, in <module>
from softwareproperties.SoftwareProperties import SoftwareProperties,
shortcut_handler
File "/usr/lib/python3/dist-packages/softwareproperties
/SoftwareProperties.py", line 67, in <module>
from gi.repository import Gio
File "/usr/lib/python3/dist-packages/gi/__init__.py", line 42, in
<module>
from . import _gi
ImportError: cannot import name '_gi' from 'gi' (/usr/lib/python3/dist-
packages/gi/__init__.py)
但是在python3中导入gi可以正常工作:
(base) marco@pc:~$ python3
Python 3.7.3 (default, Mar 27 2019, 22:11:17)
[GCC 7.3.0] :: Anaconda, Inc. on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import gi
>>>
已解决:
由于@ Smurfz87,我发现python3.7.3版本导致apt-repository出现此问题。更改/ usr / bin / add-apt-repository的第一行以指向3.6版本后:#!/ usr / bin / python3.6一切正常:
(base) marco@pc:~$ sudo add-apt-repository \
> "deb [arch=amd64] https://download.docker.com/linux/ubuntu \
> $(lsb_release -cs) \
> stable"
Hit:1 http://gb.archive.ubuntu.com/ubuntu bionic InRelease
Get:2 https://download.docker.com/linux/ubuntu bionic InRelease [64.4 kB]
Get:3 http://gb.archive.ubuntu.com/ubuntu bionic-updates InRelease [88.7
kB]
Get:4 http://gb.archive.ubuntu.com/ubuntu bionic-backports InRelease [74.6
kB]
Get:5 https://download.docker.com/linux/ubuntu bionic/stable amd64
Packages [9594 B]
Get:6 http://gb.archive.ubuntu.com/ubuntu bionic-updates/universe i386
Packages [985 kB]
Get:7 http://gb.archive.ubuntu.com/ubuntu bionic-updates/universe amd64
Packages [1017 kB]
Hit:8 http://apt.postgresql.org/pub/repos/apt bionic-pgdg InRelease
Hit:9 http://ppa.launchpad.net/certbot/certbot/ubuntu bionic InRelease
Get:10 http://security.ubuntu.com/ubuntu bionic-security InRelease [88.7
kB]
Fetched 2328 kB in 11s (217 kB/s)
Reading package lists... Done
(base) marco@pc:~$ sudo apt-get update
Hit:1 http://security.ubuntu.com/ubuntu bionic-security InRelease
Hit:2 http://apt.postgresql.org/pub/repos/apt bionic-pgdg InRelease
Hit:3 http://gb.archive.ubuntu.com/ubuntu bionic InRelease
Hit:4 http://gb.archive.ubuntu.com/ubuntu bionic-updates InRelease
Hit:5 http://gb.archive.ubuntu.com/ubuntu bionic-backports InRelease
Hit:6 http://ppa.launchpad.net/certbot/certbot/ubuntu bionic InRelease
Hit:7 https://download.docker.com/linux/ubuntu bionic InRelease
Reading package lists... Done
(base) marco@pc:~$ sudo apt-get install docker-ce docker-ce-cli
containerd.io
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following additional packages will be installed:
aufs-tools cgroupfs-mount pigz
The following NEW packages will be installed
aufs-tools cgroupfs-mount containerd.io docker-ce docker-ce-cli pigz
0 to upgrade, 6 to newly install, 0 to remove and 0 not to upgrade.
Need to get 85.6 MB of archives.
After this operation, 384 MB of additional disk space will be used.
Do you want to continue? [Y/n] Y
如何解决问题?
马可