在一些类似的问题中,这个特定的问题要么没有通过建议的解决方案解决,要么问题已经摇摆到不同的主题.因此,我不得不问这个问题:
返回的错误是:
Traceback (most recent call last):
File "learn.py", line 8, in
frame = simplegui.create_frame("Home", 300, 200)
AttributeError: 'module' object has no attribute 'create_frame'
这与以下代码有关
import simplegui
message = "Welcome!"
def click():
global message
message = "Good job!"
def draw(canvas):
canvas.draw_text(message, [50,112], 48, "Red")
frame = simplegui.create_frame("Home", 300, 200)
frame.add_button("Click me", click)
frame.set_draw_handler(draw)
frame.start()
我在Ubuntu上使用pip安装了“simplegui”,但问题似乎没有根据.请提出可行的解决方案.
解决方法:
您遇到的问题是有两个名为simplegui的库. The one on pypi(给你错误的那个)与the one for codeskulptor(你有示例代码的那个)完全不同.如果你想使用codeskulptor的示例代码,你必须在codeskulptor中运行你的代码.如果要在本地计算机上运行代码,则必须放弃codeskulptor示例代码.
标签:python,python-2-7