Q:

After installing matplotlib basemap via Macports, example python code for basemap is not running

I'm using Mac OS X 10.6.8. I installed Python 2.6 using the binary installer in http://www.python.org/. I've been using it along with SciPy and Matplotlib for my scientific computing needs since March 2011 without any problems. Recently, I have the need for the matplotlib library called Basemap.
I followed this article on https://modelingguru.nasa.gov/docs/DOC-1847. It states that the easiest way to install the Basemap library is through Macports (or Fink). So I tried to install Basemap via Macports. I executed the command 
port install py-matplotlib-basemap

and it seems to install so many things such as Python 2.4, etc. So to be specific, I used Macports again but this time using
port install py26-matplotlib-basemap 

since I'm using Python 2.6. The installation didn't seem to have any problems. 
Now I tested if Basemap was properly installed by running a Python code example that uses basemap for graphing. But the terminal says the following before coming back to the prompt:
Traceback (most recent call last):
File "basemap-test.py", line 1, in <module>
from mpl_toolkits.basemap import basemap
File "/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/mpl_toolkits/basemap/__init__.py", line 45, in <module>
import _geoslib, netcdftime
ImportError: dlopen(/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/_geoslib.so, 2): Symbol not found: _GEOSArea
Referenced from: /Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/_geoslib.so
Expected in: dynamic lookup

What may be wrong here? I know that Macports installs its own Python version, I don't know if that has an effect on this problem.

A:

As you noted, MacPorts installs its own Python version (by default, at /opt/local/bin/python2.6).  If you install a Python package via MacPorts, like basemap, you normally will need to run everything under the MacPorts Python.  Don't try to mix and match Python instances.  Packages that include C extension modules or depend on other packages which include C libraries have to be built in a way that is compatible with the way the Python interpreter was built.  The Python 2.6 installers from python.org are 32-bit-only and built to be compatible with a range of OS X versions.  By default, what MacPorts builds will be 64-bit on 10.6, if possible, and only tailored for 10.6 systems.  The safest and easiest option long term would be to switch to using the MacPorts Python, ensuring that all the packages you need are installed from MacPorts.

