python中模块没有属性_python – 模块对象没有属性’create_frame’

在一些类似的问题中,这个特定的问题要么没有通过建议的解决方案解决,要么问题已经摇摆到不同的主题.因此,我不得不问这个问题:

返回的错误是:

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

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值