Here's what I've learned: MacPorts creates its own Python installation under /opt/local/Library/Frameworks/Python.framework
which is confusingly similar to the system /Library/Frameworks/Python.framework
. It calls the latter "python27-apple" (assuming version 2.7) and you can see all the Pythons it sees by running sudo port select --list python
and you can make it use the system Python by running sudo port select python python27-apple
. Now when you run sudo port install py27-pyodbc
it should theoretically drop the library into the right folder (/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/pyodbc.so
) ... but it does NOT. You can, however, copy the two files from /opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/pyodbc*
and it'll find them.
$ cp /opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/* ./
$ python
Python 2.7.5 (v2.7.5:ab05e7dd2788, May 13 2013, 13:18:45)
[GCC 4.2.1 (Apple Inc. build 5666) (dot 3)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import pyodbc
>>> quit()
Note that this folder does not require elevated privileges as it is meant for drop-in 3rd party libraries. This is really not the best solution and I'm hoping someone else can tell me off and suggest a better one.
Reference: How to: Macports select python