Search code examples
pythongtkhomebrewpygtkpython-venv

Getting an old python script that needs gtk to work


So I'm trying to fix up an old program and I've been trying to run its main script on my Mac, but it says it can't find module gtk (it says it's a required dependency in the README). I have tried a ton of things to get this script to run, I've installed both python 2 and 3 with brew, installed many versions of pygtk with brew, tried to run the script on my user dir and in a python 2 and 3 virtualenv, added #!/usr/bin/env python2 and added a sys path to where brew installed pygtk, but all to no avail. Neither gtk nor pygtk can seem to be found. My original attempt at using pip to install pygtk resulted in this output:

Complete output from command python setup.py egg_info:
********************************************************************
* Building PyGTK using distutils is only supported on windows. *
* To build PyGTK in a supported way, read the INSTALL file.    *
********************************************************************

----------------------------------------
Command "python setup.py egg_info" failed with error code 1 in 
/private/var/folders/6l/k1kfh5415ln0886zznkffpr80000gn/T/pip-install- 
50TCjw/pygtk/

So... my question is: how should I proceed? I'm actually not sure what gtk does. Should I attempt to update this program to python3 compatibility? What is the state of compatibility for gtk? And how can I check if I actually even have gtk on my system? Because homebrew is pretty convinced that I do.

Update: So I manually used the python2.7 that was installed via brew (in usr/local/Cellar/python@2) and this seemed to fix the gtk problem. However now it can't import webkit module which is somewhere else in the program, and I'm stuck here now...


Solution

  • Finally got all the dependancies loaded. python-webkit was apparently completely deprecated, I had to find the last macOS compatible version of it at https://code.google.com/archive/p/pywebkitgtk/downloads and then it was a simple matter of running its configure file and adding its install location to my Cellar python@2 program's sys path. Now the rest of the program is pretty messed up but I accomplished what I wanted for now