简体   繁体   English

Pygame已正确安装,但不会导入python 2.7文件

[英]Pygame is correctly installed but won't import in python 2.7 file

System: OSX Yosemite 10.10.5 系统: OSX Yosemite 10.10.5

Language: Python 2.7 (must use 2.7 for class) 语言: Python 2.7(类必须使用2.7)

IDE: LiClipse IDE: LiClipse

Background: For the longest time I could NOT get pygame to work at all in python. 背景:在最长的时间内,我根本无法让pygame在python中工作。 After much research I realized that pygame for mac is 32-bit while the general python 2.7 is 64-bit. 经过大量研究,我意识到针对Mac的pygame是32位的,而一般的python 2.7是64位的。 So I uninstalled the 64-bit python and reinstalled 32-bit python 2.7. 因此,我卸载了64位python,然后重新安装了32位python 2.7。

Problem now: When I enter IDLE, I am able to write 现在的问题:输入IDLE后,我可以写

>> import pygame
>> print(pygame.ver)

and

1.9.1release

is successfully returned. 成功返回。 No problem in IDLE 闲置没问题

HOWEVER 然而

When I enter LiClipse and simply run: 当我进入LiClipse并运行时:

import pygame

The following is returned: 返回以下内容:

ImportError: No module named pygame

How is this possible if pygame can be imported in IDLE? 如果可以将pygame导入IDLE,怎么办?

确保您的IDE运行相同的python版本和相同的PYTHONPATH环境变量(从两个IDE中检查sys.versionsys.path )。

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

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