我正在尝试像这样在 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:~$
请指导我完成我所缺少的
打开终端并输入:
检查 in 中是否有一行
/etc/environment
包含CLASSPATH
不属于 in的字符串/etc/environment
。您应该注释/etc/environment
除第一行(其设置以PATH
开头)以外的所有内容,方法是在每行之前用一个字符PATH=
注释掉。使用以下命令在 nano 文本编辑器中#
打开文件进行编辑:/etc/environment
Nano 编辑器键盘快捷键
使用键盘组合Ctrl+ O,然后按下Enter将文件保存到当前位置。
使用键盘组合Ctrl+X退出 nano。