导入pygame失败 [英] import pygame fails

查看:1219
本文介绍了导入pygame失败的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我从这里安装了python 2.6.6和pygame 2.6:

http://pygame.org/ftp/pygame-1.9.1.win32-py2.6.msi



但是,当我尝试运行这个简单的程序时,我收到一个错误:

  import pygame 
pygame.init ()
pygame.quit()

错误说:


未解决导入:pygame


可能是什么? p>

编辑:
当我在做

  import pygame $解释器C:\Python26\python.exe中的


它可以正常工作。

所以这可能是一个Eclipse问题。

任何人都有一个想法该怎么办?

解决方案

p>之前

  import pygame 

添加行

  import sys 
print sys.path

如果路径为 pygame 未显示,那么您没有正确设置 PYTHONPATH 环境变量。


I have installed python 2.6.6 and pygame 2.6 from here:
http://pygame.org/ftp/pygame-1.9.1.win32-py2.6.msi

However, when I try to run this simple program, I get a an error:

import pygame
pygame.init()
pygame.quit ()

The error says:

unresolved import:pygame

What could it be?

Edit: When I am doing

import pygame

in C:\Python26\python.exe , the interpreter, it works ok.
So it is probably an Eclipse problem.
Anyone has an idea what to do?

解决方案

Before

 import pygame

add the lines

import sys
print sys.path

if the path to pygame isn't shown, then you've don't have the PYTHONPATH environment variable set correctly.

这篇关于导入pygame失败的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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