I encountered and solved this problem earlier this day and now I run into something similar but in another context.
When I fire up python (2.7) in my mac Terminal (Mac OS Lion) and do
import oursql
everything is fine.
When I do the same within a python script in the Aptana IDE I get the following error.
Traceback (most recent call last):
File "/Users/salah/Documents/Aptana Studio 3 Workspace/pubmap/src/scripts/parse_all_dblp_authors.py", line 10, in <module>
import oursql
ImportError: dlopen(/Library/Python/2.7/site-packages/oursql.so, 2): Library not loaded: libmysqlclient.18.dylib
Referenced from: /Library/Python/2.7/site-packages/oursql.so
Reason: image not found
This is the same error as in the problem above which I used to solve by adding
PATH=${PATH}:/usr/local/mysql/bin
export DYLD_LIBRARY_PATH="$DYLD_LIBRARY_PATH:/usr/local/mysql/lib/"
to .bashrc and
if [ -f ~/.bashrc ]; then
source ~/.bashrc
fi
to .bash_profile.
Why does this have no effect on Aptana? By the way Aptana is a derivate of eclipse so everything relevant to eclipse should be relevant to Aptana, too - at least I think so...
Edit:
A suggestion by Peter in his answer below brought me a possible solution. Just set the path right into the interpreter Options of Python in Aptana/Eclipse/Pydev. See the following Screenshot: