简体   繁体   English

pygame未导入

[英]pygame not being imported

I have a really basic question, pygame isn't being recognized in Windows 7. I have ActiveState Python 2.7 and pygame-1.9.2a0.win32-py2.7.msi installed. 我有一个非常基本的问题,在Windows 7中无法识别pygame。我安装了ActiveState Python 2.7和pygame-1.9.2a0.win32-py2.7.msi。 However, a simple hello world program that imports pygame gives 但是,导入pygame的一个简单的hello world程序可以

Traceback (most recent call last):
File "foo.py", line 1, in <module>
import pygame
ImportError: No module named pygame

Can anyone help me with this? 谁能帮我这个? I am not really familiar with editing the PATH if that is what is needed, thanks. 如果需要的话,我对编辑PATH并不是很熟悉,谢谢。

EDIT: Is it because ActiveState is 64 bit and I'm using the 32 bit version of pygame? 编辑:是因为ActiveState是64位,而我正在使用pygame的32位版本?

Adding pygame to the path is the first thing I would try. 我将尝试将pygame添加到路径中。

A really simple (and probably bad to leave it there but okay to test) way to get things running is to locate where your pygame is installed, and add it to sys.path 使事情运行的一种非常简单的方法(可能很难将其保留,但可以测试)是找到pygame的安装位置,并将其添加到sys.path中。

There is more info here: http://greeennotebook.com/2010/06/how-to-change-pythonpath-in-windows-and-ubuntu/ 这里有更多信息: http : //greeennotebook.com/2010/06/how-to-change-pythonpath-in-windows-and-ubuntu/

You can eventually add it to the windows PATH. 您最终可以将其添加到Windows PATH。

Ah, never mind, it appears I needed both versions of ActiveState and pygame to be 32 bit. 啊,没关系,看来我需要同时使用ActiveState和pygame的32位版本。 Works now. 现在可以使用。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM