Python 3.x 无法在Ubuntu 18.04.2 LTS上安装python3 tk
我正在运行Ubuntu 18.04.2 LTS:Python 3.x 无法在Ubuntu 18.04.2 LTS上安装python3 tk,python-3.x,ubuntu-18.04,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-
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 breaked 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)
请告知我不确定此解决方案是否适用于所有情况,但这里有一个适合我的解决方案 我也有同样的问题(除了Ubuntu 16.04),也尝试了@Column01在评论中写的内容:
sudo apt get安装python3.6-tk
同样的问题。
但这给了我一个想法。检查:
$ python --version
Python 3.5.2
因此,解决方案非常简单:
sudo apt-get install python3.5-tk
帮我个忙,检查
/usr/lib/python3.6/tkinter
是否已经存在。它说它在安装时试图覆盖它。同时尝试sudo apt get install python3.6-tk
instead@Column01是的,/usr/lib/python3.6/tkinter
存在,如果我运行sudo-apt-get-install-python3.6-tk
我会得到完全相同的错误。这意味着tkinter已经安装。尝试导入并使用它,但确保脚本使用正确的env@Column01/usr/bin/python3.6/home/user/Development/tturtle.py回溯(最近一次调用):文件“/usr/lib/python3.6/tkinter/\uu init\ukinter.py”,第37行,在导入中\u tkinter ModuleNotFoundError:没有名为“\u tkinter”的模块。