[Pythonmac-SIG] "no codec search functions registered" when /usr/bin/ in PATH

Ivan Kozik ivan@allometra.com
Mon, 23 Dec 2002 08:47:56 -0800


On Monday, December 23, 2002, at 02:02  AM, Jack Jansen wrote:
> On Monday, Dec 23, 2002, at 04:33 Europe/Amsterdam, Ivan Kozik wrote:
>
>> Hello,
>>
>> Right now I'm using the Python version built by apple (anyone know 
>> which one this is?). It almost works great (even executes 
>> Resources/__main__.py) in my .app bundle, but the problem is that I 
>> get the error message:
>> LookupError: no codec search functions registered: can't find encoding
>> when I open my program with /usr/bin in the $PATH variable.
>> For example: '/usr/bin/open -a ProgramName' does not work, while 
>> 'PATH="" /usr/bin/open -a ProgramName' does work.
>
> I haven't the foggiest idea as to what could be happening, but I think 
> it must have to do with the sys.path initialisation code. I would 
> start debugging with either turning on PYTHONVERBOSE (so you can see 
> where modules are imported from) or PYTHONINSPECT (so you get an 
> interactive interpreter after the crash, and you can look at sys.path, 
> sys.prefix and other ogoodies).
> --
> Jack Jansen, <Jack.Jansen@cwi.nl>, http://www.cwi.nl/~jack
>

The problem is that I have fink installed (and /sw/bin in the PATH), 
and apparently it was using the libraries in /sw/lib/python2.2.
I renamed python2.2 in /sw/lib to python2.2-dontuse, and then it 
started fine, even with /usr/bin in the PATH and a /usr/bin/python 
link. (It now used the libraries in 
/Library/Frameworks/Python.framework). I still do think that many users 
will have fink installed and /sw/bin in their $PATH, so is there any 
workaround for this? Does anyone know how apple compiled python? (It 
doesn't seem to have any command line switches (just ignores them), and 
it executes Bundle.app/Contents/Resources/__main__.py if one exists.) 
I'd like to recompile it and put setenv("PATH", "", 1); somewhere in 
the code.

This is what it says when I start the apple-compiled python:
Python 2.2 (#11, Jan  6 2002, 01:00:42)
[GCC 2.95.2 19991024 (release)] on darwin
Type "copyright", "credits" or "license" for more information.
 >>>

Also, the PYTHONINSPECT variable was completely ignored.

Thanks,
Ivan