Pygame won`t install on Mac OS X Lion

Joined
Apr 5, 2012
Messages
6
Reaction score
0
Points
1
Location
Brazil
Your Mac's Specs
MacMini 2007 running OS X Lion || 2GB RAM || 120GB HDD || 2,2GHz
Hey, i`m trying to install Pygame for fytoh 3.2.2 on a Mac Mini running OSX 10.7.3, and it keeps failing every single try. I`m using a tutorial from http://programming.itcarlow.ie/PyGameInstall.pdf and got every thing to work, but stuck at Step 7, to build the setup.py file.
Code:
viennamini:pygame Home$ python setup.py build
running build
running build_py
running build_ext
building 'pygame.imageext' extension
/usr/bin/gcc-4.2 -DNDEBUG -g -fwrapv -Os -Wall -Wstrict-prototypes -isysroot /Developer/SDKs/MacOSX10.6.sdk -arch i386 -pipe -Ddarwin -I/Library/Frameworks/SDL.framework/Versions/Current/Headers -I/Library/Frameworks/SDL_image.framework/Versions/Current/Headers -I/usr/local/include -I/usr/local/include -I/System/Library/Frameworks/Python.framework/Versions/2.7/include/python2.7 -c src/imageext.c -o build/temp.macosx-10.7-intel-2.7/src/imageext.o
In file included from /System/Library/Frameworks/Python.framework/Versions/2.7/include/python2.7/unicodeobject.h:4,
                 from /System/Library/Frameworks/Python.framework/Versions/2.7/include/python2.7/Python.h:85,
                 from src/pygame.h:75,
                 from src/imageext.c:47:
/Developer/SDKs/MacOSX10.6.sdk/usr/include/stdarg.h:4:25: error: stdarg.h: No such file or directory
error: command '/usr/bin/gcc-4.2' failed with exit status 1
This is the output when I run build. I checked the /Developer folder and the stdarg.h file IS there, so I`m lost. Any ideas?
 

vansmith

Senior Member
Joined
Oct 19, 2008
Messages
19,924
Reaction score
559
Points
113
Location
Queensland
Your Mac's Specs
Mini (2014, 2018, 2020), MBA (2020), iPad Pro (2018), iPhone 13 Pro Max, Watch (S6)
This doesn't answer your question directly but is there any reason that you're not using a pre-built binary (you can get them here)? That would save you a headache and some time.
 
OP
X
Joined
Apr 5, 2012
Messages
6
Reaction score
0
Points
1
Location
Brazil
Your Mac's Specs
MacMini 2007 running OS X Lion || 2GB RAM || 120GB HDD || 2,2GHz
This doesn't answer your question directly but is there any reason that you're not using a pre-built binary (you can get them here)? That would save you a headache and some time.
Well, thats the problem, they do not have binaries for Python 3.2 on Mac, just for the 2.x Python. So I tried to compile from the source, but, well, you saw the results.
EDIT: I re-checked the stdarg.h file and it is re-directing the
Code:
#include_next <stdarg.h>
to itself. Perhaps change it? Don't know what to do
 
OP
X
Joined
Apr 5, 2012
Messages
6
Reaction score
0
Points
1
Location
Brazil
Your Mac's Specs
MacMini 2007 running OS X Lion || 2GB RAM || 120GB HDD || 2,2GHz
New try

OK, i tried something else. I used MacPorts to install Pygame. Clean and swift. Then I opened Terminal and tested, both with the default Python, 2.7, and the updated one, 3.2.
For the 2.7 it went well. Imported with no errors and I actually managed to create a functional GUI.
Code:
viennamini:~ Home$ python
Python 2.7.1 (r271:86832, Jun 16 2011, 16:59:05) 
[GCC 4.2.1 (Based on Apple Inc. build 5658) (LLVM build 2335.15.00)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import pygame
>>>
BUT, for the 3.2 version, I got an error:
Code:
viennamini:~ Home$ python3
Python 3.2.2 (v3.2.2:137e45f15c0b, Sep  3 2011, 17:28:59) 
[GCC 4.2.1 (Apple Inc. build 5666) (dot 3)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import pygame
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/Library/Python/3.2/site-packages/pygame-1.9.1release-py2.7-macosx-10.7-intel.egg/pygame/__init__.py", line 95, in <module>
    from pygame.base import *
ImportError: dlopen(/Library/Python/3.2/site-packages/pygame-1.9.1release-py2.7-macosx-10.7-intel.egg/pygame/base.so, 2): Symbol not found: _PyCObject_Type
  Referenced from: /Library/Python/3.2/site-packages/pygame-1.9.1release-py2.7-macosx-10.7-intel.egg/pygame/base.so
  Expected in: flat namespace
 in /Library/Python/3.2/site-packages/pygame-1.9.1release-py2.7-macosx-10.7-intel.egg/pygame/base.so
>>>
I managed another way to install and got new problems. Any solutions for any of my problems?
 

vansmith

Senior Member
Joined
Oct 19, 2008
Messages
19,924
Reaction score
559
Points
113
Location
Queensland
Your Mac's Specs
Mini (2014, 2018, 2020), MBA (2020), iPad Pro (2018), iPhone 13 Pro Max, Watch (S6)
It would appear that Python 3.x is trying to use the 2.x version of Pygame which, as you saw, will never end well given the significant changes between 2.x and 3.x.

The Pygame website suggests that it is mostly compatible with Python 3.x. However, it says you'll have to "copy and paste" files to make it work (see here). As to what that means is a bit of a mystery but I'm guessing that this means you'll have to copy the libraries from the 2.x site-packages folder to the 3.x one.

I'm guessing Pygame will only work with a package manager (like MacPorts) if your whole Python workflow was built with MacPorts. In other words, the MacPorts pygame will work with a MacPorts compiled Python. If you're trying to use a MP Pygame with an official Python installation (or the system one), you'll probably run into trouble.
 
OP
X
Joined
Apr 5, 2012
Messages
6
Reaction score
0
Points
1
Location
Brazil
Your Mac's Specs
MacMini 2007 running OS X Lion || 2GB RAM || 120GB HDD || 2,2GHz
Thanks for the help, but still not working

Actually, the system Python works just fine with the MP installed Pygame. The real problem is with the official one.

I tried to copy-paste all the Pygame related folders from the 2.7 site-packages folder to the site-packages in the 3.2 folder, and still received an error message.

I also reinstalled Python 3.2 via MP and reinstalled Pygame also from MP. Still the error persists.:Confused:
(PORTUGUESE) VAI TOMA NO CU SEU PYTHON DE MERDA :Angry: (PORTUGUESE)

Any ideas more? I would really appreciate using Pygame with Python 3.2 on Mac, but Pygame seems to be a little hard to get working.
 

vansmith

Senior Member
Joined
Oct 19, 2008
Messages
19,924
Reaction score
559
Points
113
Location
Queensland
Your Mac's Specs
Mini (2014, 2018, 2020), MBA (2020), iPad Pro (2018), iPhone 13 Pro Max, Watch (S6)
Any ideas more? I would really appreciate using Pygame with Python 3.2 on Mac, but Pygame seems to be a little hard to get working.
This doesn't surprise me since support for Python 3.x is spotty at best (when you look at the module ecosystem as a whole). It also doesn't surprise me that it works with the system Python since that's Python 2.x.

I would imagine that the version of Pygame from MP would work with their build of Python. Thus, I wonder if you're using the binary installation of Python 3.x that you have installed without knowing it. MP installs its content to /opt/local so execute a "which python" to see what version of Python you're defaulting to. If you're defaulting to the Python.org (official) version, which will be installed to /Library/Frameworks/Python.framework/Versions, you can install the "python_select" tool from MP to switch the default.
 
OP
X
Joined
Apr 5, 2012
Messages
6
Reaction score
0
Points
1
Location
Brazil
Your Mac's Specs
MacMini 2007 running OS X Lion || 2GB RAM || 120GB HDD || 2,2GHz
I tried the "which python" and it returned /usr/bin/python, so I don`t know if this is the correct installation. If it isn`t, can you tell me how do I swich?
 

vansmith

Senior Member
Joined
Oct 19, 2008
Messages
19,924
Reaction score
559
Points
113
Location
Queensland
Your Mac's Specs
Mini (2014, 2018, 2020), MBA (2020), iPad Pro (2018), iPhone 13 Pro Max, Watch (S6)
Unfortunately, that doesn't tell me much since that could either be the system Python or the MP one if it symlinked it to /usr/bin.

Do an "ls -ld /usr/bin/python" and see if it points somewhere. You'll know it does if you get output similar to the following:
Code:
lrwxr-xr-x  1 root  wheel  75 20 Jul  2011 /usr/bin/python2.7 -> ../../System/Library/Frameworks/Python.framework/Versions/2.7/bin/python2.7
You can see there that /usr/bin/python2.7 is a symlink to /System/Library/Frameworks/Python.framework/Versions/2.7/bin/python2.7.

As for changing it, see my python_select suggestion in my previous post.
 

Shop Amazon


Shop for your Apple, Mac, iPhone and other computer products on Amazon.
We are a participant in the Amazon Services LLC Associates Program, an affiliate program designed to provide a means for us to earn fees by linking to Amazon and affiliated sites.
Top