Python 2.6.1 urllib error on Mac os x PPC

Ned Deily nad at acm.org
Mon Mar 2 16:59:54 EST 2009


In article <20090302161256.120550 at gmx.net>,
 "Attila Soki" <atiware at gmx.net> wrote:
> i trying to compile Python 2.6.1 on Mac OS X (ppc).
> After configure/make/make install i test the compiled python with
> the followig file (t.py) (example from 
> http://docs.python.org/library/urllib.html):
> -------------
> import urllib
> params = urllib.urlencode({'spam': 1, 'eggs': 2, 'bacon': 0})
> f = urllib.urlopen("http://www.musi-cal.com/cgi-bin/query", params)
> print f.read()
> -------------
> 
> and i get this error:
> 
> python /tmp/t.py 
> Traceback (most recent call last):
>   File "/tmp/t.py", line 3, in <module>
>     f = urllib.urlopen("http://www.musi-cal.com/cgi-bin/query", params)
>   File "/usr/local/test/python/lib/python2.6/urllib.py", line 82, in urlopen
>     opener = FancyURLopener()
>   File "/usr/local/test/python/lib/python2.6/urllib.py", line 611, in 
>   __init__
>     URLopener.__init__(self, *args, **kwargs)
>   File "/usr/local/test/python/lib/python2.6/urllib.py", line 129, in 
>   __init__
>     proxies = getproxies()
>   File "/usr/local/test/python/lib/python2.6/urllib.py", line 1555, in 
>   getproxies
>     return getproxies_environment() or getproxies_macosx_sysconf()
>   File "/usr/local/test/python/lib/python2.6/urllib.py", line 1449, in 
>   getproxies_macosx_sysconf
>     _CFSetup(sc)
>   File "/usr/local/test/python/lib/python2.6/urllib.py", line 1330, in 
>   _CFSetup
>     sc.CFStringCreateWithCString.argtypes = [ c_void_p, c_char_p, c_int32 ]
>   File "/usr/local/test/python/lib/python2.6/ctypes/__init__.py", line 366, 
>   in __getattr__
>     func = self.__getitem__(name)
>   File "/usr/local/test/python/lib/python2.6/ctypes/__init__.py", line 371, 
>   in __getitem__
>     func = self._FuncPtr((name_or_ordinal, self))
> AttributeError: dlsym(RTLD_DEFAULT, CFStringCreateWithCString): symbol not 
> found
> Exception AttributeError: "FancyURLopener instance has no attribute 
> 'tempcache'" in <bound method FancyURLopener.__del__ of 
> <urllib.FancyURLopener instance at 0x3743a0>> ignored
> 
> 
> The same build works on Mac Os X with intel CPU without errors. MAC OS and 
> developertools are the same on both Computer.
> 
> Mac OS X: 10.5.6
> Developertools: xcode311_2517
> How i build it:
> 
> export MACOSX_DEPLOYMENT_TARGET=10.5
> configure --prefix/usr/local/test/python
> make
> make install
> 
> How i test:
> 
> export 
> PYTHONPATH=/usr/local/test/python:/usr/local/test/python/lib/python2.6/site-pa
> ckages
> 
> /usr/local/test/python/bin/ is in the PATH
> 
> python /tmp/t.py

I'm not able to reproduce the problem building a similar configuration 
on a ppc G4 other than using Developer Tools 3.1.2.  There is also no 
problem when using 2.6.1 from the python.org OS X installer.  The test 
seems pretty basic.

A few things to try:

First, make sure this is the real problem by trying this snippet:

/usr/local/test/python/bin/python2.6
>>> from ctypes import cdll
>>> from ctypes.util import find_library
>>> sc = cdll.LoadLibrary(find_library("SystemConfiguration"))
>>> x = sc.CFStringCreateWithCString(0, "HTTPEnable", 0)

Presumably, if your original test failed, this snippet should fail, too.

If you can, download the python.org 2.6.1 OSX installer and make sure 
your original test works with it.  If so, perhaps you don't need to 
build your own?  That install works on both Intel and PPC.  One 
difference: it is built with MACOX_DEPLOYMENT_TARGET=10.3, meaning it 
will work on systems >= 10.3 but if you really need 10.5 only there 
might be some side-effects that are important to you.

Otherwise, you might want to try rebuilding on the PPC from scratch 
(i.e. an empty build directory) using the 2.6.1 tarball.  By "same 
build" on Intel CPU, you do mean you've rebuilt on PPC?  You could build 
a "fat" Universal python on either architecture that will work on both 
but you'll need to add a few more options to configure to do that.

-- 
 Ned Deily,
 nad at acm.org




More information about the Python-list mailing list