I was able to resolve this problem on macOS Sierra and a non-system Homebrew python installation (python 2.7), using the "install_name_tool" command as mentioned in http://stackoverflow.com/a/32325887.
For this to work first get the list of linked libraries using:
otool -L _ok.so
In this list you will find the curren linked python library, like:
Search for the correct location of the library. In case of Homebrew I used:
(pay attention to the correct version numbers)
then use install_name_tool to change (replace with paths):
install_name_tool -change <current> <new>