【发布时间】:2019-05-15 21:14:07
【问题描述】:
我正在运行 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)
请多指教
【问题讨论】:
-
帮我个忙,检查
/usr/lib/python3.6/tkinter是否已经存在。它说它在安装时试图覆盖它。 -
也可以试试
sudo apt-get install python3.6-tk -
@Column01 是的,
/usr/lib/python3.6/tkinter存在,如果我运行sudo apt-get install python3.6-tk,我会得到完全相同的错误。 -
这意味着 Tkinter 已经安装。尝试导入并使用它,但确保脚本使用正确的环境
-
@Column01
/usr/bin/python3.6 /home/user/Development/tturtle.py Traceback (most recent call last): File "/usr/lib/python3.6/tkinter/__init__.py", line 37, in <module> import _tkinter ModuleNotFoundError: No module named '_tkinter'