Install pygame manually in pygame _ Ubuntu

Source: Internet
Author: User

After searching for a long time, I finally found something I could use and shared it with you.
The pygame.org website is blocked by GFW and cannot be directly downloaded from mainland China. Pygame relies on other libraries such as SDL, which may cause some trouble for installation. However, compared to platform-independent powerful game development using the Python language, this is nothing.

1. Introduction

Pygame is based on Python encapsulation of the SDL library and provides Python interfaces. SDL (Simple DirectMedia Layer) is a cross-platform game development library that facilitates game development and transplantation. Currently the latest version of sdl1.2.14.: http://www.libsdl.org/download-1.2.php. SDL library Author Sam lantinga, using C language development. SDL also includes encapsulation of Perl, Erlang, pango, Ruby, and other languages.
Pygame is written by Pete Shinners. The latest stable version is 1.91.

2. Download
Pygame official website http://www.pygame.org, but is abnormal GFW shielded. If you want to visit the official website, you have to learn to go through the wall. In addition, some third-party downloads show you luck.

Or directly install the SDK through apt-Get.

Sudo apt-Get install Python-pygame

For direct download, You need to manually configure the following software.

3. Install SDL
The downloaded file is pygame-1.9.1release.tar.gz, 2 MB. Decompress the package and enter the directory for execution.
Python config. py
Prompt
SH: SDL-config: not found
SH: smpeg-config: not found

SDL is not installed. Run
Sudo aptitude install libsdl1.2-Dev
The following "new" software packages will be installed.
Libaa1-dev {A} libasound2-dev {A} libaudio-dev {A} libaudiofile-dev {}
Libcaca-dev {A} libdirectfb-extra {A} libesd0-dev {}
Libfreetype6-dev {A} libgl1-mesa-dev {A} libglu1-mesa-dev {A} libice-dev {}
Libjpeg62-dev {A} libncurses5-dev {A} libpng12-dev {A} libpthread-stubs0 {}
Libpthread-stubs0-dev {A} libsdl1.2-dev libslang2-dev {A} libsm-dev {}
Libsysfs-dev {A} libx11-dev {A} libxau-dev {A} libxcb1-dev {}
Libxdmcp-dev {A} libxext-dev {A} libxt-dev {A} Mesa-common-dev {}
X11proto-core-dev {A} x11proto-input-dev {A} x11proto-kb-dev {}
X11proto-xext-dev {A} xtrans-dev {A} zlib1g-dev {}
About 10 MB will be downloaded and installed.

Other source code and installation packages of other platforms, such as rpm, can be accessed

Http://www.libsdl.org/download-1.2.php

Find.

4. install other required software
Run Python config. py.
Prompt
Hunting dependencies...
SH: smpeg-config: not found
Warning: "smpeg-config" failed!
SDL: Found 1.2.13
Font: not found
Image: not found
Mixer: not found
Smpeg: not found
PNG: not found
JPEG: not found
Scrap: not found
Portmidi: not found
Porttime: not found

You can ignore these components to continue the installation, but some results cannot be obtained.
Run the following command to install the missing component.

Sudo apt-Get install libsdl-image1.2-dev libsdl-mixer1.2-dev libsdl-ttf2.0-dev libsdl-gfx1.2-dev libsdl-SGE-dev libsdl-net1.2-dev libportmidi-dev libsmpeg-Dev
Here, mixer is the sound mixing library, sound is the sound library, TTF is the font library, GFX, SGE, and image are all graphic processing. Smpeg is used to play MPEG movies. MIDI is used to process MIDI sound.

If Python does not install the development library, pygame cannot be installed.
Sudo apt-Get install python2.6-Dev
Install the corresponding development library based on the Python version of the machine. My Python version is 2.6.4, So I installed the 2.6 development library.
You also need to install the python numeric library for processing vector and numerical computation, which is required by some games.
Sudo apt-Get install Python-numeric Python-numpy Python-scipy

5. Install pygame. Execute again
Sudo./config. py
Hunting dependencies...
SDL: Found 1.2.13
Font: Found
Image: Found
Mixer: Found
Smpeg: Found 0.4.5
PNG: Found
JPEG: Found
Scrap: Found
Portmidi: Found
Porttime: Found

Run
Sudo Python setup. py
After the installation is successful, pygame is installed. If there is any problem, install the corresponding software and libraries according to the error.

6. Try pygame
Enter examples and run
Chmod + x *
./Aliens. py
You will see a game of tank wars. You can try other games. The following shows my pygame game screen. You can hear the sound effects of music, fire, and explosion.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.