AskOverflow.Dev

AskOverflow.Dev Logo AskOverflow.Dev Logo

AskOverflow.Dev Navigation

  • 主页
  • 系统&网络
  • Ubuntu
  • Unix
  • DBA
  • Computer
  • Coding
  • LangChain

Mobile menu

Close
  • 主页
  • 系统&网络
    • 最新
    • 热门
    • 标签
  • Ubuntu
    • 最新
    • 热门
    • 标签
  • Unix
    • 最新
    • 标签
  • DBA
    • 最新
    • 标签
  • Computer
    • 最新
    • 标签
  • Coding
    • 最新
    • 标签
主页 / ubuntu / 问题

问题[tkinter](ubuntu)

Martin Hope
burnedfaceless
Asked: 2018-08-20 14:57:36 +0800 CST

在 Ubuntu 18.04 上运行 Tkinter 程序

  • 0

我正在尝试完成本教程https://likegeeks.com/python-gui-examples-tkinter-tutorial/amp/。

我写了以下代码

from tkinter import *

window = Tk()

window.title('Welcome to LikeGeeks app')

window.mainloop()

我已经运行了命令

sudo apt install python3-tk

但是我仍然收到以下错误:

NameError: name 'Tk' is not defined

我机器上的 Python 版本是 Python 3.6.5。

海龟图形工作正常。

编辑:我将文件从 tkinter.py 重命名为 test.py 并收到此错误消息

Traceback (most recent call last):
File "test.py", line 1, in <module>
from tkinter import *
ImportError: bad magic number in 'tkinter': b'\x03\xf3\r\n'
python tkinter
  • 2 个回答
  • 11433 Views
Martin Hope
Ram Mandal
Asked: 2018-02-01 00:29:46 +0800 CST

无法在我的 ubuntu 机器 16.04 中安装 python3-tk

  • 2

我正在尝试像这样在 pycharm 中使用 tkinter 制作第一个桌面应用程序。

from tkinter import *

root = Tk()
mLabel = Label(root, text="This is Header")
mLabel.pack
mLabel.mainloop()

但我有一个例外说

ImportError: No module named '_tkinter', please install the python3-tk package

我试着像这样安装python3-tk

sudo apt-get install python3-tk

但后来我得到了一个关于install-info

ronem:::ronem:~$ sudo apt-get install python3-tk
Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following packages were automatically installed and are no longer required:
libfftw3-single3:i386 libgomp1:i386 libpam-systemd:i386 
libpulsedsp:i386 libtdb1:i386
libwebrtc-audio-processing-0:i386
Use 'sudo apt autoremove' to remove them.
The following additional packages will be installed:
blt tk8.6-blt2.5
Suggested packages:
blt-demo tix python3-tk-dbg
The following NEW packages will be installed:
blt python3-tk tk8.6-blt2.5
0 upgraded, 3 newly installed, 0 to remove and 437 not upgraded.
1 not fully installed or removed.
Need to get 0 B/604 kB of archives.
After this operation, 2,117 kB of additional disk space will be used.
Do you want to continue? [Y/n] y
Setting up install-info (6.1.0.dfsg.1-5) ...
/usr/sbin/update-info-dir: 3: /etc/environment: CLASSPATH: not found
dpkg: error processing package install-info (--configure):
subprocess installed post-installation script returned error exit 
status 127
Errors were encountered while processing:
install-info
E: Sub-process /usr/bin/dpkg returned an error code (1)
ronem:::ronem:~$ 

请指导我完成我所缺少的

package-management python3 pycharm tkinter
  • 1 个回答
  • 4559 Views

Sidebar

Stats

  • 问题 205573
  • 回答 270741
  • 最佳答案 135370
  • 用户 68524
  • 热门
  • 回答
  • Marko Smith

    如何运行 .sh 脚本?

    • 16 个回答
  • Marko Smith

    如何安装 .tar.gz(或 .tar.bz2)文件?

    • 14 个回答
  • Marko Smith

    如何列出所有已安装的软件包

    • 24 个回答
  • Marko Smith

    无法锁定管理目录 (/var/lib/dpkg/) 是另一个进程在使用它吗?

    • 25 个回答
  • Martin Hope
    Flimm 如何在没有 sudo 的情况下使用 docker? 2014-06-07 00:17:43 +0800 CST
  • Martin Hope
    Ivan 如何列出所有已安装的软件包 2010-12-17 18:08:49 +0800 CST
  • Martin Hope
    La Ode Adam Saputra 无法锁定管理目录 (/var/lib/dpkg/) 是另一个进程在使用它吗? 2010-11-30 18:12:48 +0800 CST
  • Martin Hope
    David Barry 如何从命令行确定目录(文件夹)的总大小? 2010-08-06 10:20:23 +0800 CST
  • Martin Hope
    jfoucher “以下软件包已被保留:”为什么以及如何解决? 2010-08-01 13:59:22 +0800 CST
  • Martin Hope
    David Ashford 如何删除 PPA? 2010-07-30 01:09:42 +0800 CST

热门标签

10.10 10.04 gnome networking server command-line package-management software-recommendation sound xorg

Explore

  • 主页
  • 问题
    • 最新
    • 热门
  • 标签
  • 帮助

Footer

AskOverflow.Dev

关于我们

  • 关于我们
  • 联系我们

Legal Stuff

  • Privacy Policy

Language

  • Pt
  • Server
  • Unix

© 2023 AskOverflow.DEV All Rights Reserve