Rhel: pygame安装与范例运行,以及中间出错问题的处理(redhat)

本文介绍了在Red Hat Enterprise Linux (RHEL) 上安装Python库pygame的步骤,包括前提条件、安装过程和遇到问题的解决办法,特别提到了非Windows环境下BMP图像的处理。
摘要由CSDN通过智能技术生成

一 说明:

        pygame is a library for python 3d

        pygame是python的游戏开发包。


二 前提准备

        pygame的安装前提是:

                python2.6+   和  SDL, 可以使用如下安装方式(Linux下)

        $ yum install python2.6*  SDL SDL*
        $ yum install python-image*                      # PIL: python image 处理模块

        需要使用python源代码文件       

        $yum install python-devel*

        需要使用gd,gd-devel*

        $yum install gd, gd-devel

        下载pygame:

                http://pygame.org/ftp/pygame-1.9.1release.tar.gz

        下载PyOpenGL,用于图像幀处理: 

                http://pypi.python.org/packages/source/P/PyOpenGL/PyOpenGL-3.0.1.tar.gz#md5=cdf03284f24279b8d9914bb680a37b5e

三 安装

        1. 首先安装PyOpenGL

        $ tar zxvf PyOpenGL-3.0.1.tar.gz
        $ cd PyOpenGL-3.0.1
        $ python setup.py install

        2. 其次安装 pygame

        -> 解压
        $ tar zxvf   pygame-1.9.1release.tar.gz
        $ cd  pygame-19.1release/ 
        -> 生成配置文件
        $ python config.py
        $ vim setup.in

                修改配置文件setup.in中的以下项目:

EXTRABASE =
SDL = -I/usr/include/SDL -L/usr/lib -I/usr/include/SDL -D_REENTRANT -L/usr/lib $FONT = -lSDL_ttf
IMAGE = -lSDL_image
MIXER = -lSDL_mixer
SMPEG = -lsmpeg
(...)
imageext src/imageext.c $(SDL) $(IMAGE)
(...)
image src/image.c $(SDL)

                然后编译安装:

        $ python setup.py install

四  测试

        在终端中输入python,进入python交互环境,然后输入import pygame,如果没有错误(没有任何输出),表示安装正确了。


五  注意

non Windows BMP images

是由于pygame.image模块没有被加载到pygame中来。

you can build the pygame.image module with or without the SDL_image library. 
when you don't use SDL_image, you only get support for loading BMP images. 
this is definitely the problem here, not finding the SDL_image support.

you can test if pygame.image has the SDL_image support by calling 
pygame.image.get_extended(), which will return a nonzero value if 
you can load more then just BMP. 
 From the Build file: 



评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值