Python Forum
[PyGame] python3.x installation
Thread Rating:
  • 1 Vote(s) - 1 Average
  • 1
  • 2
  • 3
  • 4
  • 5
[PyGame] python3.x installation
#1
EDIT:
This is quite outdated now. Try reading here

When first starting with pygame, i had a headache of a time figuring out how to install pygame for linux on python3.x. And anytime i reinstall one of my distro's i still have to find this to install pygame on that distro. So this was my cheat sheet for all my computers that i had to install pygame on. Feel free to add, modify anything that is needed. Especially Windows installation, because i am moslty on linux, i do not bother installing it under Windows. This cheat cheet without took me hours to figure out googling around trying to find info about. Since having it, pygame is a quick 1 minute install on a fresh distro.

windows:
https://bitbucket.org/pygame/pygame/downloads
http://www.lfd.uci.edu/~gohlke/pythonlibs/#pygame

mac:
http://www.reddit.com/r/pygame/comments/...os_x_1094/
http://www.reddit.com/r/pygame/comments/...ricks_and/

linux:
python2.x:

sudo apt-get install python-pygame 
(or whatever package manager), and assuming python is referring to python2.x, otherwise the package name would be python2-pygame

python3.x:

ImportError: /usr/local/lib/python3.2/dist-packages/pygame/base.cpython-32mu.so: undefined symbol: PyCObject_Check
This error means you are running pygame 1.9.1 under python3.x. Which has some problems. Actually i have no idea what this error means, but it means have fun with getting pygame to work with python3.x. There are some methods to getting this to work, but i found pygame 1.9.2 pre works without modification. I found the modification to 1.9.1 would work in Ubuntu, but not in Arch, whereas pygame 1.9.2 pre worked in every distro i tried. 

1) Download the latest pygame 1.9.2 pre and extract it 
https://launchpad.net/debian/experimenta...rce/pygame

OR
sudo apt-get install mercurial
hg clone https://bitbucket.org/pygame/pygame
 
2) if you already installed 1.9.1, and installed it under python3.x, then remove it:
in directory: ( replace python3.2, with whichever version you have

/usr/local/lib/python3.2/dist-packages
execute these two commands:

sudo rm -r pygame
sudo rm pygame-1.9.1release.egg-info

3) install python3 pygame dependencies:

sudo apt-get install python3-dev python-dev libsdl-image1.2-dev libsdl-mixer1.2-dev libsdl-ttf2.0-dev libsdl1.2-dev libsmpeg-dev python3-numpy python-numpy subversion libportmidi-dev libfreetype6-dev
(which some are not python3 pygame dependant, but whatever)
for example if you do not download python3.dev you will get this error:
src/pygame.h:75:20: fatal error: Python.h: No such file or directory compilation terminated. error: command 'i686-linux-gnu-gcc' failed with exit status 1
4) change directory to the newly donwloaded/extracted pygame directory and execute:

sudo python3 setup.py install

5)
Hunting dependencies...
SDL     : found 1.2.14
FONT    : found
IMAGE   : found
MIXER   : found
SMPEG   : found 0.4.5
PNG     : found
JPEG    : found
SCRAP   : found
PORTMIDI: found
PORTTIME: found
AVFORMAT: not found
SWSCALE : not found
FREETYPE: found 2.4.8


Warning, some of the pygame dependencies were not found. Pygame can still
compile and install, but games that depend on those missing dependencies
will not run. Would you like to continue the configuration? [Y/n]:
will display that some games may not work, etc. yatta yatta, hit y for yes. Although make sure SDL is found, MPEG,  IMAGE, FONT. i have not yet came across a game that i couldnt run, yet, with these two that were not found.

6) confirm installation:

metulburr@ubuntu:~$ python3
Python 3.2.3 (default, Oct 19 2012, 20:10:41) 
[GCC 4.6.3] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import pygame
>>> 
if you get the prompt, you are good to go.

EDIT: well i get sick of redoing this with every ubuntu distro, so this now replaces theis whole thing as it does more than just pygame https://github.com/metulburr/distro_setup

EDIT2:
I tried the latest python 3.3 with Pygame 1.9.2 and it failed, however python3.2 worked with it. So you may have to tinker around with the versions possibly.

EDIT3:
I did end up getting python3.4 working with a pygame version for arch linux. PAckage is:
https://aur.archlinux.org/packages/python-pygame-hg/

makepkg -s
sudo pacman -U *.xz
metulburr@rch ~/Downloads/python-pygame-hg $ python
Python 3.4.0 (default, Mar 17 2014, 23:20:09) 
[GCC 4.8.2 20140206 (prerelease)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import pygame
>>> exit()
metulburr@rch ~/Downloads/python-pygame-hg $ 
Recommended Tutorials:
Reply
#2
This isnt as much a problem these days as it was then...but hey better this site have the data than the old forums.  :D
Recommended Tutorials:
Reply


Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020