[Pythonmac-SIG] Python 2.2.2 and Tkinter installation problems on OS X

Nicholas Riley njriley@uiuc.edu
Tue, 26 Nov 2002 18:08:20 -0600


On Tue, Nov 26, 2002 at 11:37:41PM +0100, Jack Jansen wrote:
> can you try running pythonw outside of the build directory and report 
> your findings back? It could be that something goes wrong because the 
> algorithm that finds sys.path knows about the build directory.

Sorry, I should have mentioned that.  It does the same thing.

> The error about the codec search function is very weird, has anyone 
> else seen anything like it?

Thanks for suggesting that I take another look at this; I've found the
problem!

>From searching Google with the text of the error message it appears
'import codecs' is necessary.  Here's what happened when I ran it with
each of the three Pythons (build dir python.exe, python, pythonw):

python.exe: 
>>> import codecs
>>> codecs
<module 'codecs' from '/Users/nicholas/src/Python-2.2.2/Lib/codecs.py'>

python:
>>> import codecs
Traceback (most recent call last):
  File "<stdin>", line 1, in ?
  File "/Library/Frameworks/Python.framework/Versions/2.2/lib/python2.2/codecs.py", line 10, in ?
    import struct, __builtin__
ImportError: No module named struct

pythonw:
>>> import codecs
LookupError: no codec search functions registered: can't find encoding

The second example gave me a clue.  It was a permissions problem;
struct.so was installed like this:

  -rwx--x--x    1 root     admin         61k Nov 26 12:39 struct.so*

After fixing the permissions, codecs and Tk in pythonw work properly.
Hooray!

What needs fixing in Python, IMO, is:

- The permissions on installed files in lib/dynload should be properly
  set.  Perhaps it picked up my umask, which is 077?  But then they'd
  be rwx------, so I don't know...).  Using the 'install' program to
  install files is usually the right way to do this, as it uses
  rwxr-xr-x by default.

  I did a 'find . -perm 711' in Python.framework and the only other
  file I found outside lib/dynload that had the wrong permissions was
  pydoc.

- "no module named struct" should be distinguished from "can't access
  struct module to import it".

- In the third case of pythonw, the import error was somehow
  suppressed; it should be displayed.  If it were, the resultant
  error would not be so cryptic.

Now onto fixing metakit's native code module, which somehow outputs a
.dylib (shared lib) instead of a .so (bundle)...

-- 
=Nicholas Riley <njriley@uiuc.edu> | <http://www.uiuc.edu/ph/www/njriley>
        Pablo Research Group, Department of Computer Science and
  Medical Scholars Program, University of Illinois at Urbana-Champaign