python-ibmdb: Mac libdb2.dylib image not found
>>> import ibm_db
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: dlopen(/usr/local/lib/python3.5/site-packages/ibm_db.cpython-35m-darwin.so, 2): Library not loaded: libdb2.dylib
Referenced from: /usr/local/lib/python3.5/site-packages/ibm_db.cpython-35m-darwin.so
Reason: image not found
This issue can be solved by running
cd /usr/local/lib/python3.5/site-packages
install_name_tool -change libdb2.dylib `pwd`/libdb2.dylib ibm_db.cpython-35m-darwin.so
http://thecourtsofchaos.com/2013/09/16/how-to-copy-and-relink-binaries-on-osx/
However, this needs to be run after pip compiles it. http://stackoverflow.com/questions/1321270/how-to-extend-distutils-with-a-simple-post-install-script
About this issue
- Original URL
- State: closed
- Created 9 years ago
- Comments: 23
Commits related to this issue
- Add OSX django workaround to the docs for #187 — committed to kdazzle/python-ibmdb by kdazzle 8 years ago
This is what helped me:
Change the path to your site-packages for your virtualenv. The
ln -s
command was what resolved my issue. Theinstall_name_tool
alone did not help me. Hopefully this helps@theodoretliu not sure to be honest lol I think I noticed that the
libdb2.dylib
didn’t exist so I created a symlink and then it worked.I fixed the the Exception by adding:
AUTHENTICATION=SERVER
.However now in ibm_db_django I get the same error as above. I need to find out how to pass
AUTHENTICATION=SERVER
to the connection.I was having the same error and found that the installDSDriver script creates a file at /Applications/dsdriver/db2profile stating the below:
so I just added on my ~/.bash_profile the line below:
source /Applications/dsdriver/db2profile
Open a new terminal window or restart your mac and should work. This file exports all the environment variables needed for the db2cli command to work.
none of the above approaches fixed my issue with libdb2.dylib I am on a Mac and Python 3.6.5 :: Anaconda, Inc.
if you dont want to alter your
bash_profile
then you can add thisto
./venv/bin/activate
.My approach in fixing this was to add this to my bash profile:
I did this after identifying where
libdb2.dylib
was located which I did on my mac by doing the ff steps:Reactivate the bash profile with
source ~/.bash_profile
and voila, problem solvedusing python 2.7.13
@genomics-geek thanks for all your help!
@genomics-geek You are absolutely awesome. This gave me grief for 6 hours+. Yes!
Above problem and solution is discussed in the following blog, please follow the #2 in blog: https://www.ibm.com/developerworks/community/blogs/96960515-2ea1-4391-8170-b0515d08e4da/entry/ibm_db_on_MAC_OS_Hints_and_Tips?lang=en