Python AttributeError:“模块"对象没有属性“初始化" [英] Python AttributeError: 'module' object has no attribute 'init'

查看:175
本文介绍了Python AttributeError:“模块"对象没有属性“初始化"的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在运行一个简单的python文件:

I was running a simple python file:

from livewires import games

games.init(screen_width = 640, screen_height = 480, fps = 50)

games.screen.mainloop()

当我在IDLE中运行它时,我得到了标题中打印的错误. 我从一本书中复制并粘贴了此代码.我处在初学者的早期阶段,所以我所知不多.我相当确定我已经正确安装了带电电线,因为我已经使用其模块运行了其他程序. (天哪,我知道那可能根本不是正确的术语,对不起.)我并不是在寻找一种解决此问题的方法,(尽管那也很好),我只是希望有人可以解释一下到底是什么问题.我从一本书中复制了代码,所以我不明白自己做错了什么.我也100%肯定没有错字.

When I run this in IDLE, I get the error printed in the title. I copy and pasted this code from a book. I'm at the early stages of a beginner, so I don't know much. I'm fairly sure that I installed livewires properly as i've already run other programs with its modules. (gosh, I know that that is probably not the right terminology at all, sorry.) I'm not exactly looking for a way to fix this, (although that'd be nice, too) I'm just hoping someone could explain exactly what the problem is. I copied the code from a book so I don't understand what I did wrong. I'm 100% positive that there are no typos, too.

推荐答案

好吧,四处搜寻,看来这是在线直播网站: Livewires主页,从中可以下载其livewires软件包.

Well, searching around, it seems that this is the livewires website: Livewires Home Page where one can download their livewires package.

此外,还提供了一些代码:章11 看起来就像他在这里发布的内容("The Pizza Panic Game").

Also, some code from this: Chapter 11 looks like what he's posted here ("The Pizza Panic Game").

下载和解压缩直播电线表明,游戏模块中确实没有任何init功能(正如已经提到的注释).

Downloading and unpacking livewires shows that there is indeed no init function in the games module (as the comments already mentioned).

这本书中都有不可行的示例(令人怀疑,鉴于其对这个示例的深度解释);或在编写本书和现在之间,livewires软件包已更改(很有可能).

Either this book has non-working examples (doubtful, given the depth it explains this example with); or the livewires package has changed between when the book was written and now (much more likely).

livewires网站上还有其他示例,我想您将会获得更多成功.
我建议您抛弃这本书,因为您可能会继续遇到这样的障碍.通过Google搜索,您会发现许多其他免费的python教程,这些教程是最新的,并且更容易理解.

The livewires website has other examples on it which I think you'll have much more success with.
I'd recommend you ditch the book, since it's likely you'll keep running into roadblocks like this. A Google search will turn up a number of other free python tutorials which are more up-to-date, and will be easier to follow.

此页面上有一些面向初学者的链接:初学者指南

This page has a few links for beginners: Beginners Guide

这篇关于Python AttributeError:“模块"对象没有属性“初始化"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆