Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
210 views
in Technique[技术] by (71.8m points)

python - Pygame attribute, init()

I'm trying to use Pygame with Python 3.3 on my windows 8 laptop. Pygame installed fine and when I import pygame it imports fine as well. Although when I try to execute this small code:

import pygame

pygame.init()

size=[700,500]
screen=pygame.display.set_mode(size)

I get this error:

Traceback (most recent call last):
  File "C:Users
amedocumentspythonpygame_example.py", line 3, in <module>
    pygame.init()
AttributeError: 'module' object has no attribute 'init'

I used pygame-1.9.2a0-hg_56e0eadfc267.win32-py3.3 to install Pygame. Pygame is installed in this location 'C:PythonX' and Python 3.3 is installed in this location 'C:Python33'. I have looked at other people having the same or similar problem and it doesn't seem to solve the error. Have I done anything wrong when installing Pygame? Or does it not support windows 8?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

After import pygame pygame.init()

I got this error message and programm didnt work: " AttributeError: module 'pygame' has no attribute 'init' "

because i named the file "pygame.py"...

When i chaned filename to "pygametest.py" everything worked.

Naming the filename exactly like the modulename seems to confuse python...


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...