pygame error loading [duplicate] - macos

I recently bought a new macbook and I've been trying endlessly to get pygame to work, but haven't succeeded yet. I'm getting pretty desperate and I could really use some help.
I've installed pygame 1.9.4 and even though I don't get any error messages when running pygame code, it won't show me anything but a blank screen. I'm using the following code to test it:
import pygame
pygame.init()
screen = pygame.display.set_mode((800,600))
while True:
for event in pygame.event.get():
if event.type == pygame.QUIT:
quit()
screen.fill((255,0,0))
pygame.display.update()
pygame.quit()
On my old macbook the test code gives me a red screen as expected. Both macbooks are running python 2.7.10.
Does anyone have any idea what I'm doing wrong? I think I installed pygame exactly like I did on my old macbook and the only difference seems to be the operating system.
edit 1:
I write the script in Sublime Text and run the program in Terminal.
Screenshot
edit 2:
I got pygame working again by downgrading my operating system to macOS High Sierra.

Tested and works on macOS 10.15 Catalina, Python 3.7.5, PyGame 2.0.0 (pre-release as of this writing) and PyGame 1.9.6 (stable as of this writing).
Initially you need to decide if you want a stable release or a pre-release (unstable). If you decide to use the latest (and possibly pre-release/unstable) then just ignore the first step ("1. Find the latest stable release version") and use master branch at step 4 of the second step ("2. Install PyGame from source").
1. Find the latest stable release version
Go to PyGame's GitHub page here:
As you can see as of this writing the latest stable release is 1.9.6 so we hold this tag name for later.
2. Install PyGame on macOS from source
Install some dependencies brew install sdl2 sdl2_gfx sdl2_image sdl2_mixer sdl2_net sdl2_ttf. This requires homebrew.
Go to site-packages:
For virtual environment go to cd ~/.virtualenvs/myvirtualenv/lib/python3.X/site-packages where ~/.virtualenvs/myvirtualenv is the path to your virtual environment and python3.X is the version of your Python.
For system-wide installation go to /usr/local/lib/python3.X/site-packages where python3.X is the version of your Python.
Delete any previous pygame, pip uninstall pygame (if a pygame directory exists in site-packages then remove it: rm -rf pygame*)
Clone PyGame from GitHub:
git clone https://github.com/pygame/pygame.git for the latest (possibly not stable version).
git clone -b 1.9.6 https://github.com/pygame/pygame.git --single-branch for the latest (1.9.6 is the tag name of the latest stable release, as of this writing, see "Find the latest stable release version above")
Go into the newly cloned pygame directory: cd pygame.
Run python setup.py --config --auto --sdl2.
If you get problems with this command, some users below mentioned that single hyphens worked for them, therefore try: python setup.py -config -auto -sdl2.
If you get any problems regarding Python2/3 and you are targeting Python3 try to change python setup.py --config --auto --sdl2 to python3 setup.py --config --auto --sdl2.
Run python setup.py install (it will take a while).
If you get any problems regarding Python2/3 and you are targeting Python3 try to change python setup.py --config --auto --sdl2 to python3 setup.py --config --auto --sdl2.
Now PyGame should work as expected on macOS.

I also face this problem on the macOS Catalina. Actually it is a version problem of pygame. Firstly I have installed with the following command:
pip3 install pygame
An only blank screen was showing. But later on, I have changed the version with the following command:
pip3 install pygame==2.0.0.dev4
With this version my problem was solved. It was working perfectly.

LATEST UPDATE for MacOS 10.14.1
If you download the official macOS x64 installer package of Python 3.7.2 from the official python.org page and type pip3 install pygame, it works.
There's an issue with MacOS. It should be possible to fix in SDL.
https://discourse.libsdl.org/t/macos-10-14-mojave-issues/25060/8
https://bugzilla.libsdl.org/show_bug.cgi?id=4274
The pygame issue is here: https://github.com/pygame/pygame/issues/555
The homebrew issue is here: https://github.com/Homebrew/homebrew-core/issues/33016

I ran into this issue using macOS Catalina version 10.15.2, Python 3.7.2 and pygame 1.9.6. I upgraded to Python 3.8.1, Pygame 2.0.0.dev6 and it is now working as expected.

I tried upgrading my old macbook to OS Mojave to see if pygame would stop working, and it did!
I guess Mojave isn't compatible with pygame (yet).
Thanks for the help!

Edit with working workaround:
see bottom of post
I get the same problem on a MacBook Pro (Retina display) with python3.7 and MacOs Mojave.
For the sake of simplicity, I did all my tests with your exact same code and pygame 1.9.4.
On (two) Windows computers, the program works and shows a red window on :
python2.7
python3.6
python3.7
Hence it doesn't seem to be a Python version problem, I lean toward a MacOS Mojave problem.
Mojave introduced 'Dark mode' which automatically tint windows. When dark mode is disabled, I get a blank screen. When it is enabled, I get a dark screen. Might it be that MacOS takes control of the screen display and fiddles with the way pygame controls the screen? It is just a theory but I don't know how to test it.
Edit:
I tried a pygame program that records and prints the position of the screen on which you clicked. It does output the position in the console, alas it doesn't display anything.
Apart from the faulty display, pygame seems to work properly.
Edit:
For now, using the Python version from miniconda and using CogSci's pygame seems to work.

I've tried everything but nothing worked except this:
pip install git+https://github.com/pygame/pygame.git
This installs the tips of the pygame. It worked for me. Give it a try.

I ran into this problem with the following environment: Python 3.7, Mojave 10.14.2, Pygame 1.9.4
I found that downgrading to Python 3.6 fixes the issue
$ brew unlink python
$ brew install https://raw.githubusercontent.com/Homebrew/homebrew-core/f2a764ef944b1080be64bd88dca9a1d80130c558/Formula/python.rb
That should fix it, if you get a circular dependency problem you should then run:
$ brew install --ignore-dependencies https://raw.githubusercontent.com/Homebrew/homebrew-core/f2a764ef944b1080be64bd88dca9a1d80130c558/Formula/python.rb
Details at https://apple.stackexchange.com/questions/329187/homebrew-rollback-from-python-3-7-to-python-3-6-5-x

I had the same issue, got it to work by downgrading python to 3.6.5.
> brew unlink python brew install --ignore-dependencies
> https://raw.githubusercontent.com/Homebrew/homebrew-core/f2a764ef944b1080be64bd88dca9a1d80130c558/Formula/python.rb
> brew switch python 3.6.5_1 pip3 install pygame
If you already have python 3.6.5 install I guess you can just use switch.

Some macs need updates. If you go to system preferences and you go to software updates, you could try updating to see if it needs any updates. When you update, you can check to see if your code works now because it looks like your code is correct.

Related

Is there new version of pygame for anaconda env?

I have pygame in pip environment and used it without problem.
But now I switched to conda environment (called tf-gpu) to have TF features also.
As I figured out the most used channel for conda version of pygame is cogsci.
But conda install -c cogsci pygame in terminal causes an error:
It seems there is a version incompatibility.
I then downloaded the original tar.bz2 file from conda, and tried conda install --offline C:\...(file path)
It downloaded and recognized by interpreter(python 3.8.8, conda('tf_gp' env)).
Then Pyhton imported pygame but error of there is no module "from python.base import *" proceeded it.(as it is in the __init__ file of package)
Are these problem due to old version of pygame? I tried other channels in anaconda but unsuccessful(also they were older).
And also i can not downgrade python because of many packages' prerequisites.
I also tried installing via pip(in that conda promp), but it said that the requirment has been satisfied(as i previoisly used pygame in pip env(python 3.8.2).
Is there any new conda version of pygame?
Should i remove previous pygame in pip and try pip install again in conda env?
Or is it possible to modify main package source code(old file)?
This issue usually comes in when you are running many versions of python and pygame together which causes some incompatibility. Another problem which may occur is that anaconda environment stop recognising the pygame as it can’t locate it.
My suggestion is that uninstall all the older versions of python and pygame and install the latest ones.
Or else you may shift to Visual studio code for better experience and lesser problems.
Thanks,
The problem was solved by uninstalling other python version that I had(3.6). and using pip version of pygame(which did not work when two python versions (3.6, 3.8) were on my system.)

AllenNLP Torch Version Unavailable

I am trying to install allennlp via pip on the latest version of macOS Catalina. The Python version is 3.9.0. The pip version is 20.2.4.
I was just able to install only a couple of weeks ago, but now I receive the following error when I run the command:
pip3 install allennlp allennlp-models
ERROR: No matching distribution found for torch<1.8.0,>=1.6.0 (from allennlp)
This is really bad because a time-sensitive project I am working on right now completely depends on allennlp working. I needed to reinstall due to some git issues, and my virtual env was reset. What can I do to resolve this issue?
Thanks.
EDIT: Somehow I ended up uninstalling 3.9 in homebrew and now I'm stuck at jsonnet. It errors out. I saw some posts about this issue, but none of the recommendations work.
EDIT2: I tried reinstalling brew's python 3.9. jsonnet standalone works again, but then I have the pytorch issue again.
I'm stuck in a loop. Neither the system macOS 3.8 python nor the latest 3.9 home-brew python works. I'd rather get the home-brew python working, but there's no valid version of torch available for that one apparently.
Do NOT accidentally use home-brew to download the latest Python 3.9. That isn't compatible with a lot of the required libraries.
Phew.

Problems getting pygame to show anything but a blank screen on Macos

I recently bought a new macbook and I've been trying endlessly to get pygame to work, but haven't succeeded yet. I'm getting pretty desperate and I could really use some help.
I've installed pygame 1.9.4 and even though I don't get any error messages when running pygame code, it won't show me anything but a blank screen. I'm using the following code to test it:
import pygame
pygame.init()
screen = pygame.display.set_mode((800,600))
while True:
for event in pygame.event.get():
if event.type == pygame.QUIT:
quit()
screen.fill((255,0,0))
pygame.display.update()
pygame.quit()
On my old macbook the test code gives me a red screen as expected. Both macbooks are running python 2.7.10.
Does anyone have any idea what I'm doing wrong? I think I installed pygame exactly like I did on my old macbook and the only difference seems to be the operating system.
edit 1:
I write the script in Sublime Text and run the program in Terminal.
Screenshot
edit 2:
I got pygame working again by downgrading my operating system to macOS High Sierra.
Tested and works on macOS 10.15 Catalina, Python 3.7.5, PyGame 2.0.0 (pre-release as of this writing) and PyGame 1.9.6 (stable as of this writing).
Initially you need to decide if you want a stable release or a pre-release (unstable). If you decide to use the latest (and possibly pre-release/unstable) then just ignore the first step ("1. Find the latest stable release version") and use master branch at step 4 of the second step ("2. Install PyGame from source").
1. Find the latest stable release version
Go to PyGame's GitHub page here:
As you can see as of this writing the latest stable release is 1.9.6 so we hold this tag name for later.
2. Install PyGame on macOS from source
Install some dependencies brew install sdl2 sdl2_gfx sdl2_image sdl2_mixer sdl2_net sdl2_ttf. This requires homebrew.
Go to site-packages:
For virtual environment go to cd ~/.virtualenvs/myvirtualenv/lib/python3.X/site-packages where ~/.virtualenvs/myvirtualenv is the path to your virtual environment and python3.X is the version of your Python.
For system-wide installation go to /usr/local/lib/python3.X/site-packages where python3.X is the version of your Python.
Delete any previous pygame, pip uninstall pygame (if a pygame directory exists in site-packages then remove it: rm -rf pygame*)
Clone PyGame from GitHub:
git clone https://github.com/pygame/pygame.git for the latest (possibly not stable version).
git clone -b 1.9.6 https://github.com/pygame/pygame.git --single-branch for the latest (1.9.6 is the tag name of the latest stable release, as of this writing, see "Find the latest stable release version above")
Go into the newly cloned pygame directory: cd pygame.
Run python setup.py --config --auto --sdl2.
If you get problems with this command, some users below mentioned that single hyphens worked for them, therefore try: python setup.py -config -auto -sdl2.
If you get any problems regarding Python2/3 and you are targeting Python3 try to change python setup.py --config --auto --sdl2 to python3 setup.py --config --auto --sdl2.
Run python setup.py install (it will take a while).
If you get any problems regarding Python2/3 and you are targeting Python3 try to change python setup.py --config --auto --sdl2 to python3 setup.py --config --auto --sdl2.
Now PyGame should work as expected on macOS.
I also face this problem on the macOS Catalina. Actually it is a version problem of pygame. Firstly I have installed with the following command:
pip3 install pygame
An only blank screen was showing. But later on, I have changed the version with the following command:
pip3 install pygame==2.0.0.dev4
With this version my problem was solved. It was working perfectly.
LATEST UPDATE for MacOS 10.14.1
If you download the official macOS x64 installer package of Python 3.7.2 from the official python.org page and type pip3 install pygame, it works.
There's an issue with MacOS. It should be possible to fix in SDL.
https://discourse.libsdl.org/t/macos-10-14-mojave-issues/25060/8
https://bugzilla.libsdl.org/show_bug.cgi?id=4274
The pygame issue is here: https://github.com/pygame/pygame/issues/555
The homebrew issue is here: https://github.com/Homebrew/homebrew-core/issues/33016
I ran into this issue using macOS Catalina version 10.15.2, Python 3.7.2 and pygame 1.9.6. I upgraded to Python 3.8.1, Pygame 2.0.0.dev6 and it is now working as expected.
I tried upgrading my old macbook to OS Mojave to see if pygame would stop working, and it did!
I guess Mojave isn't compatible with pygame (yet).
Thanks for the help!
Edit with working workaround:
see bottom of post
I get the same problem on a MacBook Pro (Retina display) with python3.7 and MacOs Mojave.
For the sake of simplicity, I did all my tests with your exact same code and pygame 1.9.4.
On (two) Windows computers, the program works and shows a red window on :
python2.7
python3.6
python3.7
Hence it doesn't seem to be a Python version problem, I lean toward a MacOS Mojave problem.
Mojave introduced 'Dark mode' which automatically tint windows. When dark mode is disabled, I get a blank screen. When it is enabled, I get a dark screen. Might it be that MacOS takes control of the screen display and fiddles with the way pygame controls the screen? It is just a theory but I don't know how to test it.
Edit:
I tried a pygame program that records and prints the position of the screen on which you clicked. It does output the position in the console, alas it doesn't display anything.
Apart from the faulty display, pygame seems to work properly.
Edit:
For now, using the Python version from miniconda and using CogSci's pygame seems to work.
I've tried everything but nothing worked except this:
pip install git+https://github.com/pygame/pygame.git
This installs the tips of the pygame. It worked for me. Give it a try.
I ran into this problem with the following environment: Python 3.7, Mojave 10.14.2, Pygame 1.9.4
I found that downgrading to Python 3.6 fixes the issue
$ brew unlink python
$ brew install https://raw.githubusercontent.com/Homebrew/homebrew-core/f2a764ef944b1080be64bd88dca9a1d80130c558/Formula/python.rb
That should fix it, if you get a circular dependency problem you should then run:
$ brew install --ignore-dependencies https://raw.githubusercontent.com/Homebrew/homebrew-core/f2a764ef944b1080be64bd88dca9a1d80130c558/Formula/python.rb
Details at https://apple.stackexchange.com/questions/329187/homebrew-rollback-from-python-3-7-to-python-3-6-5-x
I had the same issue, got it to work by downgrading python to 3.6.5.
> brew unlink python brew install --ignore-dependencies
> https://raw.githubusercontent.com/Homebrew/homebrew-core/f2a764ef944b1080be64bd88dca9a1d80130c558/Formula/python.rb
> brew switch python 3.6.5_1 pip3 install pygame
If you already have python 3.6.5 install I guess you can just use switch.
Some macs need updates. If you go to system preferences and you go to software updates, you could try updating to see if it needs any updates. When you update, you can check to see if your code works now because it looks like your code is correct.

Installing PySide on Mac: is there a working method?

I may be doing something wrong, but I have been trying to install pyside on Mac 10.12 (Sierra). Here is what I tried (after installing Qt with brew):
With the precompiled package (1.2.1); fails because of "incompatible package".
With sudo -H pip install pyside (1.2.4): fails with the following error:
Qt QTGUI library not found.
Qt QTXML library not found.
Qt QTCORE library not found.
CMake Error at ApiExtractor/CMakeLists.txt:82 (qt4_add_resources):
Unknown CMake command "qt4_add_resources".
With brew install pyside==1.2.2 : works successfully but when calling it from a python program, fails with ImportError: dlopen(/Library/Python/2.7/site-packages/PySide/QtCore.so, 2): Libmrary not loaded: libpyside-python2.7.1.2.dylib
Referenced from: /Library/Python/2.7/site-packages/PySide/QtCore.so
Reason: unsafe use of relative rpath libpyside-python2.7.1.2.dylib in /Library/Python/2.7/site-packages/PySide/QtCore.so with restricted binary
The last one did offer some hope, and I tried PySide import error Mac OS X El Capitan, Library not loaded: #rpath/libpyside.cpython-34m.1.2.dylib . Unfortunately, the explanation was quite elliptic and I ended up breaking things further.
Am I missing something obvious? The fact that the precompiled packages are old and the web doc is not updated, that brew install does not seem to work (and the documentation makes no mention of it) and generally number of questions asked about pyside and the technical complication of the answers do not seem very good signs.
Does someone know what the matter is with PySide's installation on Mac OS, technically? What's the best solution in my particular case?
More generally, is there hope for improvement with PySide on Mac?
Update (25 Jan 2017): Workaround?
Since we are waiting for an update from Pyside, is someone willing to take the challenge of installing 1.2.2 on OS Sierra with brew, and resolve the "unsafe use of relative path"? Perhaps propose a step-by-step tutorial?
That might save the day for PySide on Mac... while relieving the time pressure on the Pyside development team?
I have MAC osSierra (10.12.6). I needed to install PySide 1.2.4 for Python 3.3.6. I did the following to build and install PySide 1.2.4 that I need. You can do the following for any Python 3.3.x, I guess.
I am a newbie to Mac and Python. Please ignore if I have any mistakes.
Install pyenv
brew install pyenv
Install Python 3.3.6 using pyenv
pyenv install 3.3.6
Add python 3.3.6 into system path
PATH="/Users/myname/.pyenv/versions/3.3.6/bin:${PATH}"
export PATH
Install Xcode from app store, then run the following. Xcode download and install took 30-40 minutes for me.
xcode-select --install
sudo xcodebuild -license
Install cmake
brew install cmake
Verify cmake is installed. I see version 3.10.0 installed
cmake —version
Tap qt4. Note: I tried qt5, but pyside build is not working for me with qt5.
brew tap cartr/qt4
brew tap-pin cart/qt4
Install qt#4.
brew install qt#4
Verify qmake is installed. I see version 2.01a installed
qmake —version
(If qmake is not recognized, create links to it using below command)
brew link cartr/qt4/qt#4 —-force
If you are using “PySide.QtWebKit” in your programs, you need to install qt-webkit. Install pyside (1.2.2 ??), which will install qt-webkit. I am not sure if qt-webkit can be installed directly, if so someone can correct me.
brew install pyside
Download PySide 1.2.4 tar file.
wget https://pypi.python.org/packages/source/P/PySide/PySide-1.2.4.tar.gz
Untar the tar file
tar -xvf PySide-1.2.4.tar.gz
Go into the folder
cd PySide-1.2.4
Build pyside. This build step took almost 30-40 minutes for me
python setup.py bdist_wheel
Verify that “dist” folder is created and it has pyside wheel file in it.
Go into the “dist” folder
cd dist
Instal PySide, last step!!
pip install PySide-1.2.4-cp33-cp33m-macosx_10_12_x86_64.whl
Congratulations!, now you have PySide 1.2.4 for Python 3.3.x
This isn't the answer but unfortunately there has not been any output from pyside team for macOS sierra .Only supported OS from apple are
10.6 Snow LeopardOS X
10.7 LionOS X
10.8 Mountain LionOS X
10.9 MavericksOS X
10.10 Yosemite
Update : (You can try this still )
curl -O https://raw.githubusercontent.com/Homebrew/homebrew-core/fdfc724dd532345f5c6cdf47dc43e99654e6a5fd/Formula/qt5.rb
brew install ./qt5.rb
If above lines doesn't work :
You’ll need the Xcode commandline tools:
xcode-select --install sudo xcodebuild -license
Then the following packages can be easily installed via brew:
brew install qt5 cmake libxslt libxml2
This will install Qt 5.6.1-1 and cmake 3.5.2 your system
Now time to clone ! Not from github but from this link :
So Clone the pyside-setup repository and have it also pull down its gitmodules:
git clone --recursive https://codereview.qt-project.org/pyside/pyside-setup
This command worked fine for people using Python 2.7.11 and Python 3.5.1. Remember to have pip installed with the wheel package or you’ll get an error about bdist_wheel.
python setup.py bdist_wheel --ignore-git --qmake=/usr/local/Cellar/qt5/5.6.1-1/bin/qmake --cmake=/usr/local/bin/cmake --openssl=/usr/local/Cellar/openssl/1.0.2h_1/bin
(Note :
The exact paths given in the arguments may not be identical on your system so verify those prior to compiling)
Install the wheel :
A wheel was hopefully built in the dist folder. So just cd dist and pip install away!
Notes on pre-compiled wheels
Unfortunately, and like with PySide, these wheels are not “portable” and won’t install on systems which doesn’t already have the specific Qt5 version installed used during compilation. This, I believe, is because PySide2 links dynamically (instead of statically) against the Qt5 installation. Hopefully, this is something The Qt Company will address via official PySide2 wheels, as Riverbank Software is now providing a fully portable PyQt5 wheel for Python 3 which is absolutely awesome.
New Repository (not from github)
Reference
The Mac steps from here worked for me: https://fredrikaverpil.github.io/2016/08/17/compiling-pyside2/
You’ll need the Xcode commandline tools:
xcode-select --install
sudo xcodebuild -license
Then the following packages, easily installed via brew:
brew install qt5 cmake libxslt libxml2
Clone the pyside-setup repository and have it also pull down its gitmodules:
git clone --recursive https://codereview.qt-project.org/pyside/pyside-setup
Build it. This command worked fine for me using Python 2.7.11 and Python 3.5.1. Remember to have pip installed with the wheel package or you’ll get an error about bdist_wheel.
cd pyside-setup
python setup.py bdist_wheel --ignore-git --qmake=/usr/local/Cellar/qt5/5.6.1-1/bin/qmake --cmake=/usr/local/bin/cmake --openssl=/usr/local/Cellar/openssl/1.0.2h_1/bin
Last but not least, install the wheel:
cd dist
pip install PySide2-2.0.0.dev0-cp27-cp27m-macosx_10_12_x86_64.whl
All credits go to Fredrik Averpil's wonderful post.
You need a specific version of Qt and pyside.
Install both the QT 4.8.5 package as well as pyside from the Mac installers on the page below:
https://wiki.qt.io/PySide_Binaries_MacOSX
You need QT4 to install PySide on 10.11 (not sure about 10.12).
Install QT5 either via Brew or via installer, get cmake via brew and get the latest PySide source (https://pypi.python.org/packages/source/P/PySide/PySide-1.2.4.tar.gz) Run the following to get Qt4:
brew tap cartr/qt4
brew tap-pin cartr/qt4
brew install qt_4
Once you do so; cd in the source folder and run the following to build:
python setup.py bdist_wheel --ignore-git --qmake=[QMAKE_FROM_QT4_PATH] --cmake=[YOUR_CMAKE_PATH]
cd dist
pip install [YOUR_BUILT_PYSIDE_WHEEL]
Once you do so, you can check that PySide is working correctly, opening a Python console and typing import PySide
I still not have a solution, but I found an alternative.
First of all, I am not an expert (I am super new coding). Based on my own experience below you will find a solution as well.
I need to clarify something first, there are two ways to use this GUI QT - PyQt by Riverbank Computing or(and) PySide, originally developed by Nokia.
I tried many differents ways to install PySide on my MacOS Sierra version10.12.5, but no success, so I ended up finding PyQt, that does the same thing.
Watching this video I installed the PyQT5 in my Mac OS and now it is working. https://www.youtube.com/watch?v=2kHk8ZjxH64
Example of Hello World using PyQT http://pythoncentral.io/intro-to-pysidepyqt-basic-widgets-and-hello-world/
The wiki.qt.io says "PySide has included support for Python 3.2 since version 1.0.8." but it doesn't work for me.
Good lucky.

Where is PyGTK for Mac OS X?

Is there a binary out there for the current mac os x, python for PyGTK? I work with multiple desktop environments (mac, windows, gnome) and really consider python's lack of cross platform GUI's a problem. Does anyone know where I can find a built version of PyGTK and GTK for Mac?
I cant clone the git repository, it keeps timing out.
brew install pygtk worked for me (requires homebrew).
Confirmed to work with OS X 10.10 too, but by default it will install it into brew's Python distribution, so if you are still using the native python, it will not find it.
I don't use macports but it seems that jhbuild works for me. Below is the steps that I've done.
download gtk-osx-build-setup.sh from: https://raw.github.com/jralls/gtk-osx-build/master/gtk-osx-build-setup.sh and save it to your home directory.
fire up terminal and navigate to your home directory and run the command sh gtk-osx-build-setup.sh
the shell script will warn you that ~/.local/bin isn't added to your environment variable to do this, edit your .profile file located at your home directory and /Users/<username>/.local/bin to your environment variable. to know more on how to edit this file check out: http://www.tech-recipes.com/rx/2621/os_x_change_path_environment_variable/
after that, do a ~/.local/bin/jhbuild bootstrap command. it will download and install some necessary utilities.
download and install the beta version of the gtk+ osx framework at: http://ftp.imendio.com/pub/imendio/gtk-osx/Gtk-Framework-2.14-LATEST.dmg
before installing the meta-gtk-osx-python, you need to build and install some other packages that jhbuild doesn't install automatically, so what i did was i installed libpng by doing the command: ~/.local/bin/jhbuild build libpng
you also need to install libtiff so do the command: ~/.local/bin/jhbuild build libtiff
and also gtk-doc is needed so: ~/.local/bin/jhbuild build gtk-doc
and finally you can now install meta-gtk-osx-python by doing a: ~/.local/bin/jhbuild build meta-gtk-osx-python
Let me know if it works.
There is an installer for PyGTK 2.24 in test here, announced on the PyGTK list.
UPDATE project has moved on macpkg's sourceforge page.
I couldn't make it work with meld (segmentation fault), but sample PyGTK programs work OK.
UPDATE 2 since then a new package Py3GTK3 appeared on the same sourceforge page. Haven't tested though.
There is now a mac package on sourceforge
Download the latest package from http://sourceforge.net/projects/macpkg/files/PyGTK/ and install.
If you're just trying to use the system python, this is all you'll have to do.
If you're not, the following is how to install it with pyenv, which can be installed with Homebrew. With brew installed, you can install version pyenv and Python 2.7.8 with:
brew install pyenv && pyenv install 2.7.8
After you've done that, you'll then have copy the gtk package and its dependencies into your python installation:
cd /opt/gtk/lib/python2.7/site-packages/ && \
cp * ~/.pyenv/versions/2.7.8/lib/python2.7/site-packages/
That's it. You can also similarly install the Py3GTK3 package which has packages for python 2.7 and 3.2 from http://sourceforge.net/projects/macpkg/files/Py3GTK3/.
Have you tried doing it using macports? This website shows how.

Resources