Discussion:
[Pythoncard-users] installing PythonCard on Mac OS X Leopard, Snow Leopard, Lion, etc.
Kevin Altis
2012-06-02 21:52:49 UTC
Permalink
I tried installing PythonCard 0.8.2 on a new Mac OS X Lion machine and ran into an old problem. The solution (update a method in util.py) was posted on this list back in July 2009, but I thought I would recap what to do if you want to run PythonCard on a Mac today. If you follow the instructions and still have a problem, please respond to this message. This is mostly a recap of the existing install directions on the main PythonCard site, but with updated Python and wxPython links.

I downloaded Python 2.7.3 universal...
http://www.python.org/ftp/python/2.7.3/python-2.7.3-macosx10.6.dmg
wxPython...
http://downloads.sourceforge.net/wxpython/wxPython2.8-osx-unicode-2.8.12.1-universal-py2.7.dmg
and PythonCard...
http://prdownloads.sourceforge.net/pythoncard/PythonCard-0.8.2.tar.gz

I ran Python.mpkg after mounting the Python disk image.

I verified that Python was installed correctly by opening the Terminal application and typing python at the command-prompt:

My-MacBook-Air:~ nobody$ python
Python 2.7.3 (v2.7.3:70274d53c1dd, Apr 9 2012, 20:52:43)
[GCC 4.2.1 (Apple Inc. build 5666) (dot 3)] on darwin
Type "help", "copyright", "credits" or "license" for more information.

Type Control-d to exit Python.

I ran the wxPython pkg after mounting the wxPython disk image.

Double-clicking on PythonCard-0.8.2.tar.gz decompressed PythonCard-0.8.2 folder into the downloads folder. Then with the Terminal window still open I switched to the directory and ran the installer. If you downloaded PythonCard to a different directory, then use that directory instead of Downloads.

cd ~/Downloads/PythonCard-0.8.2
sudo python setup.py install

You'll be prompted to type your password.

After you have PythonCard installed, it will be necessary to make a modification to the file util.py located at /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/PythonCard/util.py

In util.py, change the following method to simplify the bundlebuilder check rather than having it checking for specific versions of MacPython...

def main_is_frozen():
if sys.platform == 'darwin':
# this is a temporary hack for bundlebuilder
return not (sys.executable.endswith('Resources/Python.app/ Contents/MacOS/Python'))
else:
return (hasattr(sys, "frozen") or # new py2exe, McMillan
hasattr(sys, "importers") # old py2exe
or imp.is_frozen("__main__")) # tools/freeze, cx_freeze

That was the only change I had to make to get the samples, resourceEditor, codeEditor, etc. to run on OS X Lion 10.7.4 using Python 2.7.3 universal and wxPython 2.8.12.1 unicode and PythonCard 0.8.2 downloaded from SourceForge.

Since I installed the universal version of Python, it is necessary to specify to use the 32-bit version of python since the version of wxPython is limited to running in 32-bit mode because it uses the Carbon API. I'm not recommending installing the 32-bit version of Python because I don't think it supports OS X 10.7 (Lion).

In Python Launcher specify /usr/local/bin/python-32 or /usr/local/bin/pythonw-32 for running scripts. From the terminal just type python-32 where you would have typed python for running from the command-line. For some reason, Python Launcher stays open after launching scripts. I don't know if that is a OS X Lion bug or something else that I've missed. I don't have that problem on my Snow Leopard boxes.

Finally, as far as I can tell, there is no way to get Run or Run with interpreter menu items in the resourceEditor and codeEditor to work with the current universal build of Python and wxPython. The error message says there is 'no matching architecture in universal wrapper'. I'm guessing that if you install a 32-bit version of Python and wxPython that problem would go away. Instead, just run scripts from the terminal or Finder.

ka
h***@ktb.net
2012-06-04 06:05:27 UTC
Permalink
Post by Kevin Altis
I tried installing PythonCard 0.8.2 on a new Mac OS X Lion machine and ran
into an old problem. The solution (update a method in util.py) was posted
on this list back in July 2009, but I thought I would recap what to do if
you want to run PythonCard on a Mac today. If you follow the instructions
and still have a problem, please respond to this message. This is mostly a
recap of the existing install directions on the main PythonCard site, but
with updated Python and wxPython links.
I downloaded Python 2.7.3 universal...
http://www.python.org/ftp/python/2.7.3/python-2.7.3-macosx10.6.dmg
wxPython...
http://downloads.sourceforge.net/wxpython/wxPython2.8-osx-unicode-2.8.12.1-universal-py2.7.dmg
and PythonCard...
http://prdownloads.sourceforge.net/pythoncard/PythonCard-0.8.2.tar.gz
I ran Python.mpkg after mounting the Python disk image.
I verified that Python was installed correctly by opening the Terminal
My-MacBook-Air:~ nobody$ python
Python 2.7.3 (v2.7.3:70274d53c1dd, Apr 9 2012, 20:52:43)
[GCC 4.2.1 (Apple Inc. build 5666) (dot 3)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
Type Control-d to exit Python.
I ran the wxPython pkg after mounting the wxPython disk image.
Double-clicking on PythonCard-0.8.2.tar.gz decompressed PythonCard-0.8.2
folder into the downloads folder. Then with the Terminal window still open
I switched to the directory and ran the installer. If you downloaded
PythonCard to a different directory, then use that directory instead of
Downloads.
cd ~/Downloads/PythonCard-0.8.2
sudo python setup.py install
You'll be prompted to type your password.
After you have PythonCard installed, it will be necessary to make a
modification to the file util.py located at
/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/PythonCard/util.py
I opened this file in BBEdit and it has 420 lines of code.
Post by Kevin Altis
In util.py, change the following method to simplify the bundlebuilder
check rather than having it checking for specific versions of MacPython...
# this is a temporary hack for bundlebuilder
return not (sys.executable.endswith('Resources/Python.app/ Contents/MacOS/Python'))
return (hasattr(sys, "frozen") or # new py2exe, McMillan
hasattr(sys, "importers") # old py2exe
or imp.is_frozen("__main__")) # tools/freeze, cx_freeze
Does this code replace the block of lines 14 through 23?
Post by Kevin Altis
That was the only change I had to make to get the samples, resourceEditor,
codeEditor, etc. to run on OS X Lion 10.7.4 using Python 2.7.3 universal
and wxPython 2.8.12.1 unicode and PythonCard 0.8.2 downloaded from
SourceForge.
Since I installed the universal version of Python, it is necessary to
specify to use the 32-bit version of python since the version of wxPython
is limited to running in 32-bit mode because it uses the Carbon API. I'm
not recommending installing the 32-bit version of Python because I don't
think it supports OS X 10.7 (Lion).
In Python Launcher specify /usr/local/bin/python-32 or
/usr/local/bin/pythonw-32 for running scripts.
Kevin Altis
2012-06-04 14:24:00 UTC
Permalink
Yes, the main_is_frozen method is the only thing that gets changed.

ka
Post by Kevin Altis
After you have PythonCard installed, it will be necessary to make a
modification to the file util.py located at
/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/PythonCard/util.py
I opened this file in BBEdit and it has 420 lines of code.
Post by Kevin Altis
In util.py, change the following method to simplify the bundlebuilder
check rather than having it checking for specific versions of MacPython...
# this is a temporary hack for bundlebuilder
return not (sys.executable.endswith('Resources/Python.app/ Contents/MacOS/Python'))
return (hasattr(sys, "frozen") or # new py2exe, McMillan
hasattr(sys, "importers") # old py2exe
or imp.is_frozen("__main__")) # tools/freeze, cx_freeze
Does this code replace the block of lines 14 through 23?
Kevin Altis
2012-06-09 19:28:44 UTC
Permalink
Make sure that the line

return not (sys.executable.endswith('Resources/Python.app/Contents/MacOS/Python'))

does not contain any spaces, etc. in the string
'Resources/Python.app/Contents/MacOS/Python'

I just realized that somewhere in the process of posting to the list the code got corrupted.

ka

On Jun 2, 2012, at 2:52 PM, Kevin Altis wrote:

def main_is_frozen():
if sys.platform == 'darwin':
# this is a temporary hack for bundlebuilder
return not (sys.executable.endswith('Resources/Python.app/Contents/MacOS/Python'))
else:
return (hasattr(sys, "frozen") or # new py2exe, McMillan
hasattr(sys, "importers") # old py2exe
or imp.is_frozen("__main__")) # tools/freeze, cx_freeze

Loading...