无法在Ubuntu 18.04.2 LTS上安装python3-tk

时间:2019-05-15 21:14:08

标签: python-3.x ubuntu-18.04

我正在运行Ubuntu 18.04.2 LTS:

user@vmubu01:~$ lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description:    Ubuntu 18.04.2 LTS
Release:    18.04
Codename:   bionic

而且我无法使用“ apt-get install”命令安装python3-tk,如下所示:

user@vmubu01:~$ 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 upgraded, 1 newly installed, 0 to remove and 91 not upgraded.
3 not fully installed or removed.
Need to get 0 B/101 kB of archives.
After this operation, 891 kB of additional disk space will be used.
(Reading database ... 206924 files and directories currently installed.)
Preparing to unpack .../python3-tk_3.6.8-1~18.04_amd64.deb ...
Unpacking python3-tk:amd64 (3.6.8-1~18.04) ...
dpkg: error processing archive /var/cache/apt/archives/python3-tk_3.6.8-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.8-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.8-1~18.04_amd64.deb
E: Sub-process /usr/bin/dpkg returned an error code (1)

我也无法使用pip进行安装,请参见以下错误:

user@vmubu01:~$ pip3.6 install python3-tk
Collecting python3-tk
  ERROR: Could not find a version that satisfies the requirement python3-tk (from versions: none)
ERROR: No matching distribution found for python3-tk

如果我尝试运行“ apt --fix-broken install”命令,则会得到:

user@vmubu01:~$ sudo apt --fix-broken install
Reading package lists... Done
Building dependency tree       
Reading state information... Done
Correcting dependencies... Done
The following additional packages will be installed:
  python3-tk
Suggested packages:
  tix python3-tk-dbg
The following NEW packages will be installed:
  python3-tk
0 upgraded, 1 newly installed, 0 to remove and 91 not upgraded.
3 not fully installed or removed.
Need to get 0 B/101 kB of archives.
After this operation, 891 kB of additional disk space will be used.
Do you want to continue? [Y/n] Y
(Reading database ... 206924 files and directories currently installed.)
Preparing to unpack .../python3-tk_3.6.8-1~18.04_amd64.deb ...
Unpacking python3-tk:amd64 (3.6.8-1~18.04) ...
dpkg: error processing archive /var/cache/apt/archives/python3-tk_3.6.8-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.8-1+xenial1
Errors were encountered while processing:
 /var/cache/apt/archives/python3-tk_3.6.8-1~18.04_amd64.deb
E: Sub-process /usr/bin/dpkg returned an error code (1)

我请告知

1 个答案:

答案 0 :(得分:0)

不确定此解决方案是否适合每种情况,但这是对我有用的解决方案。

我遇到了同样的问题(Ubuntu 16.04除外),还尝试了@ Column01在注释中写的内容:
sudo apt-get install python3.6-tk

同样的问题。 但这给了我一个主意。已检查:

$ python --version
Python 3.5.2

所以解决方案很简单:

sudo apt-get install python3.5-tk