Lubuntu 18.04 python3版本是3.6.10
~$ python3 --version
Python 3.6.10
尝试安装 tkinter 模块时,它似乎指向 3.6.9 版本并且失败:
~$ sudo apt-get install python3.6-tk
Reading package lists... Done
Building dependency tree
Reading state information... Done
Note, selecting 'python3-tk' instead of 'python3.6-tk'
Suggested packages:
tix python3-tk-dbg
The following NEW packages will be installed:
python3-tk
0 to upgrade, 1 to newly install, 0 to remove and 23 not to upgrade.
Need to get 119 kB of archives.
After this operation, 1,324 kB of additional disk space will be used.
Get:1 http://au.archive.ubuntu.com/ubuntu bionic-updates/main amd64 python3-tk amd64 3.6.9-1~18.04 [119 kB]
Fetched 119 kB in 0s (599 kB/s)
(Reading database ... 481569 files and directories currently installed.)
Preparing to unpack .../python3-tk_3.6.9-1~18.04_amd64.deb ...
Unpacking python3-tk:amd64 (3.6.9-1~18.04) ...
dpkg: error processing archive /var/cache/apt/archives/python3-tk_3.6.9-1~18.04_amd64.deb (--unpack):
trying to overwrite '/usr/lib/python3.6/tkinter/__init__.py', which is also in package libpython3.6-stdlib:amd64 3.6.10-1+xenial1
dpkg-deb: error: paste subprocess was killed by signal (Broken pipe)
Errors were encountered while processing:
/var/cache/apt/archives/python3-tk_3.6.9-1~18.04_amd64.deb
E: Sub-process /usr/bin/dpkg returned an error code (1)
apt-缓存:
~$ apt-cache policy libpython3.6-stdlib python3-tk
libpython3.6-stdlib:
Installed: 3.6.10-1+xenial1
Candidate: 3.6.10-1+xenial1
Version table:
*** 3.6.10-1+xenial1 100
100 /var/lib/dpkg/status
3.6.9-1~18.04 500
500 http://au.archive.ubuntu.com/ubuntu bionic-updates/main amd64 Packages
3.6.8-1~18.04.3 500
500 http://security.ubuntu.com/ubuntu bionic-security/main amd64 Packages
3.6.5-3 500
500 http://au.archive.ubuntu.com/ubuntu bionic/main amd64 Packages
python3-tk:
Installed: (none)
Candidate: 3.6.9-1~18.04
Version table:
3.6.9-1~18.04 500
500 http://au.archive.ubuntu.com/ubuntu bionic-updates/main amd64 Packages
3.6.5-3 500
500 http://au.archive.ubuntu.com/ubuntu bionic/main amd64 Packages
$ sudo apt-get install libpython3.6-stdlib=3.6.9-1~18.04
[sudo] password for gdhp:
Reading package lists... Done
Building dependency tree
Reading state information... Done
Some packages could not be installed. This may mean that you have
requested an impossible situation or if you are using the unstable
distribution that some required packages have not yet been created
or been moved out of Incoming.
The following information may help to resolve the situation:
The following packages have unmet dependencies:
libpython3.6-stdlib : Depends: libpython3.6-minimal (= 3.6.9-1~18.04) but 3.6.10-1+xenial1 is to be installed
E: Unable to correct problems, you have held broken packages.
[1]+ Done code .
$ sudo apt-get install python3-tk
Reading package lists... Done
Building dependency tree
Reading state information... Done
Suggested packages:
tix python3-tk-dbg
The following NEW packages will be installed:
python3-tk
0 to upgrade, 1 to newly install, 0 to remove and 23 not to upgrade.
Need to get 0 B/119 kB of archives.
After this operation, 1,324 kB of additional disk space will be used.
(Reading database ... 481569 files and directories currently installed.)
Preparing to unpack .../python3-tk_3.6.9-1~18.04_amd64.deb ...
Unpacking python3-tk:amd64 (3.6.9-1~18.04) ...
dpkg: error processing archive /var/cache/apt/archives/python3-tk_3.6.9-1~18.04_amd64.deb (--unpack):
trying to overwrite '/usr/lib/python3.6/tkinter/__init__.py', which is also in package libpython3.6-stdlib:amd64 3.6.10-1+xenial1
dpkg-deb: error: paste subprocess was killed by signal (Broken pipe)
Errors were encountered while processing:
/var/cache/apt/archives/python3-tk_3.6.9-1~18.04_amd64.deb
E: Sub-process /usr/bin/dpkg returned an error code (1)
答案1
因此我建议从官方 Ubuntu 存储库安装软件包:
sudo apt-get install libpython3.6-stdlib=3.6.9-1~18.04
sudo apt-get install python3-tk