我刚安装了Kali liveusb并开始运行,我想通过编写一些我在windows设备上编写的代码来熟悉这个系统。长话短说,我不能让一些非常基本的tkinter代码工作,所以我去了超级基本。结果我只有当我是root或者sudo的时候才能让它运行。见下文。在ben@kali:/usr/lib/python3.2$ python
Python 3.2.3 (default, Feb 20 2013, 14:44:27)
[GCC 4.7.2] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> from tkinter import *
>>> t = Tk()
No protocol specified
Traceback (most recent call last):
File "", line 1, in
File "tkinter/__init__.py", line 1701, in __init__
self.tk = _tkinter.create(screenName, baseName, className, interactive, wantobjects, useTk, sync, use)
_tkinter.TclError: couldnt connect to display ":0.0"
>>>
ben@kali:/usr/lib/python3.2$ sudo python
Python 3.2.3 (default, Feb 20 2013, 14:44:27)
[GCC 4.7.2] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> from tkinter import *
>>> t = Tk()
>>>
正如您所看到的,当不以root身份运行python时,使用sudoforpython时,tkinter突然起作用了(显然您看不到窗口,但它起作用了)。我对linux很陌生,真的不知道从哪里开始。我确实尝试过tkinter文件夹上的chmod777,但似乎没有效果。任何想法都会非常有帮助。谢谢你