[Pythonmac-SIG] dyld trying to link against wrong version of Python

Bob Ippolito bob at redivi.com
Wed Dec 29 11:30:59 CET 2004


On Dec 28, 2004, at 1:51 PM, Kersey Black wrote:

> I first confess to being a newbie, but that will probably be obvious.
> I am trying to set up my powerbook for python work.  It has 10.3.7,  
> current dev xcode tools, etc.
>
> I want Numeric, numarrray, and scipy modules.
> I thought I would upgrade to python 2.4, and tried to do so with a  
> framework install.  I ran into problems (getting waste to link in the  
> compile), and realized, that having never used a mac for development  
> (I do have unix experience) I would be better sticking to the core  
> system already provided, Python 2.3.
>
> I then tried to use the package manager in MacPython-2.3 to install  
> Numeric and numarray (from different sites). Numeric worked, numarray  
> did not and was very out of date.  So, i tried to compile the new  
> version(1.1.1).  I had some trouble with getting it to install, and  
> while struggling with that I realized i better get rid of all traces  
> of the aborted install of Python-2.4 framework.

I would recommend not using anything from the undefined.org repository.  
  I do not actively maintain it, so everything is out of date.  I have  
no plans to update it until the infrastructure behind the package  
management crap changes, because what we have now is nasty and I just  
don't have time for it.

> I removed"
> /Library/Frameworks/Python.framework  [the default installation site  
> for 2.4 build]
> /Library/Python
> /Applications/MacPython-2.4
> ~/.idlerc
> /System/Library/Frameworks/Python.framwork/Versions/2.3/Headers/ 
> numarray
> and any preference files I could find related to python.

You forgot to remove your build directories.. see below.

> over a couple of more times through this, I also
> removed and reinstalled /Applications/MacPython-2.3 (twice)
>
> I have removed other modules (Numeric, PIL. OpenGL), because I am not  
> sure if there are conflicts.
>
> Here is the problem:
> I build and install numarray-1.1.1 into the /Library/Python directory
> I start Python-2.3 and ask for it to import numarray
> here is what I get:
> Traceback (most recent call last):
>   File "<stdin>", line 1, in ?
>   File  
> "/System/Library/Frameworks/Python.framework/Versions/2.3/lib/ 
> python2.3/site-packages/numarray/__init__.py", line 42, in ?
>     from numarrayall import *
>   File  
> "/System/Library/Frameworks/Python.framework/Versions/2.3/lib/ 
> python2.3/site-packages/numarray/numarrayall.py", line 1, in ?
>     from numerictypes import *
>   File  
> "/System/Library/Frameworks/Python.framework/Versions/2.3/lib/ 
> python2.3/site-packages/numarray/numerictypes.py", line 35, in ?
>     import numinclude
>   File  
> "/System/Library/Frameworks/Python.framework/Versions/2.3/lib/ 
> python2.3/site-packages/numarray/numinclude.py", line 4, in ?
>     import _ndarray
> ImportError: Failure linking new module:  
> /Library/Frameworks/Python.framework/Versions/2.4/Python: dyld: python  
> can't open library:  
> /Library/Frameworks/Python.framework/Versions/2.4/Python  (No such  
> file or directory, errno = 2)
>
> It is still trying to link against a Python-2.4, even though I think I  
> have removed all traces.
> Why is it trying to find the long since removed Python-2.4??

Because it was linked when the Python 2.4 framework existed.

> Further,
> if I import sys, and then import numarray, the import error is the  
> same.
> BUT, if I import sys, try to import numarray which generates the same  
> error above, then type sys.path, and then import numarray, the error  
> goes away, but the import seems to have failed none the less.

Python imports will fail once, and then leave a broken module in  
sys.modules, so a second import will erroneously succeed.  It's dumb,  
but that's how Python works.

> >>> sys.path
> ['',  
> '/System/Library/Frameworks/Python.framework/Versions/2.3/lib/ 
> python23.zip',  
> '/System/Library/Frameworks/Python.framework/Versions/2.3/lib/ 
> python2.3',  
> '/System/Library/Frameworks/Python.framework/Versions/2.3/lib/ 
> python2.3/plat-darwin',  
> '/System/Library/Frameworks/Python.framework/Versions/2.3/lib/ 
> python2.3/plat-mac',  
> '/System/Library/Frameworks/Python.framework/Versions/2.3/lib/ 
> python2.3/plat-mac/lib-scriptpackages',  
> '/System/Library/Frameworks/Python.framework/Versions/2.3/lib/ 
> python2.3/lib-tk',  
> '/System/Library/Frameworks/Python.framework/Versions/2.3/lib/ 
> python2.3/lib-dynload',  
> '/System/Library/Frameworks/Python.framework/Versions/2.3/lib/ 
> python2.3/site-packages']
> >>> import numarray
> >>> numarray.__version__
> Traceback (most recent call last):
>   File "<stdin>", line 1, in ?
> AttributeError: 'module' object has no attribute '__version__'
>
> Any help would be greatly appreciated.  Again, why is numarray  
> thinking there is a 2.4 version.  In other environments I would just  
> reinstall Python-2.3 from the ground up, but working from the Apple  
> CDs I do not see how to do that.  If anyone knows how to do that, it  
> could also be a solution, or not.

This is a bug in Python 2.3.0 that has been discussed A LOT on this  
list, most recently  
<http://mail.python.org/pipermail/pythonmac-sig/2004-December/ 
thread.html#12403>.

Your "phantom framework" problem is because you didn't clobber the  
build directory for numarray.  It cached the incorrectly built  
extensions that were compiled when the Python 2.4 framework was  
present.  Kill the build directory and compile/install again.

-bob



More information about the Pythonmac-SIG mailing list