views:

37

answers:

1

I am having trouble installing matplotlib on mac os 10.6, so I used macports and installed all dependencies it needed, which is great, but on top of it a new python version. Now I have two python versions and that bothers me. The matplotlib is working fine on the macport python, and the rest of my stuff is with the default python. What is the best solution for integrating both into one, and which one to use as the default python?

I tried copying all packages from my default python /defaultPython/../site-packages into the /opt/../site-packages. Same thing would be to add /defaultPython/../site-packages on the PYTHONPATH of macports python. Some did work fine, but not all.

For example on import scipy.sparse I got this error

import _csr ImportError: dlopen(/opt/local/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/scipy/sparse/sparsetools/_csr.so, 2): no suitable image found. Did find: /opt/local/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/scipy/sparse/sparsetools/_csr.so: no matching architecture in universal wrapper

Any thoughts or dirty fix for this?

Thanks a lot!

+1  A: 

You should never remove or alter the system Python that Apple supplies with Mac OS X -- that's the specific build they've tested their OS with, and you really don't want to break that.

If you want to use handy macports-installed extensions, you need the macports version of Python for that purpose, so you can't remove that either.

There is no real reason to worry because you have more than one Python version on your system (I typically have at least half a dozen on mine;-).

Just put /opt/... (wherever macports keeps its bin directory) at the start of your PATH environment variable (e.g. in .bashrc) and make sure you install with the macports Python any extension you need there.

Alex Martelli
Thanks for the quick reply. /opt/... is already added on my PATH. I would like to be able to call one script, say python test.py, which imports packages from both. My matplotlib is installed with the macports, and the rest of my packages are installed with my default version. Any ideas how to do this?
Oliver
@Oliver, what you want to do is impossible: you just have to install all the packages directly or indirectly used in a given script on the _same_ version of Python, and then use that version to run the script.
Alex Martelli
Thanks Alex. I edited the question. Maybe you know a fix for this?
Oliver
Copying is not enough: packages containing any machine code must be **installed** for the specific Python version! I repeat: you have to redo the needed installs for whatever Python version you choose, **NOT** just copy things around.
Alex Martelli
How about the .dmg packages? I wanna install the scipy dmg, but can't change the directory, or how do I make it for the macports python. Alex, thanks for the help, I am new to Mac, and besides last month I was working on iMac and did not have problems with installing matplotlib, but now I am on a mac book pro which should be the same but I am running into problems, can't remember what I did differently.
Oliver
@Oliver, as http://projects.scipy.org/scipy/browser/scipy.org/source/download.rst?rev=6054 says, "If you are using Python provided by Fink or MacPorts it is recommended that you install NumPy/SciPy with the appropriate package" then they point to http://trac.macports.org/browser/trunk/dports/python/py26-numpy/Portfile and http://trac.macports.org/browser/trunk/dports/python/py26-scipy/Portfile . The .dmg is built for Apple's Python, not macports', and it won't work with the latter (just like macports' packages won't work w/Apple's Python, of course!).
Alex Martelli