Python-MySQLdb MAMP problem: path to libssl.1.0.0.dylib, changing after the Python file is called

I am trying to use python MySQLdb to access my MySQL database on my MAMP server.

When I initially tried to call a Python file with python-sql to access my MAMP database, I received an image not found error regarding the libssl.1.0.0.dylib library

  Traceback (most recent call last): File "desktopsql.py", line 3, in <module> import _mysql as ms File "build/bdist.macosx-10.5-x86_64/egg/_mysql.py", line 7, in <module> File "build/bdist.macosx-10.5-x86_64/egg/_mysql.py", line 6, in __bootstrap__ ImportError: dlopen(/Users/username/.python-eggs/MySQL_python-1.2.5-py2.7-macosx- 10.5-x86_64.egg-tmp/_mysql.so, 2): Library not loaded: libssl.1.0.0.dylib Referenced from: /Users/username/.python-eggs/MySQL_python-1.2.5-py2.7-macosx-10.5-x86_64.egg-tmp/_mysql.so Reason: image not found 

So I fixed it to a certain extent by changing the path libssl.1.0.0.dylib using export DYLD_LIBRARY_PATH=/Users/username/anaconda/lib/:$DYLD_LIBRARY_PATH , but this needs to be done for each folder in which I want to execute the Python file .

Therefore, when I try to execute a Python file through PHP in my MAMP webpage, I get an error again, and I cannot use my interim fix this time to hide it.

I tried to fix it further using install_name_tool to change the location of the false library /Users/username/.python-eggs/MySQL_python-1.2.5-py2.7-macosx-10.5-x86_64.egg-tmp/_mysql.so to where it is actually stored in /Users/username/anaconda/lib/

 sudo install_name_tool -change libssl.1.0.0.dylib /Users/username/anaconda/lib/libssl.1.0.0.dylib /Users/username/.python-eggs/MySQL_python-1.2.5-py2.7-macosx-10.5-x86_64.egg-tmp/_mysql.so 

After that, I use otool -L to view the status of what I changed, and the result indicates that the file path has , of course, been changed to the correct location.

 otool -L /Users/username/.python-eggs/MySQL_python-1.2.5-py2.7-macosx-10.5-x86_64.egg-tmp/_mysql.so /Users/username/anaconda/lib/libssl.1.0.0.dylib (compatibility version 1.0.0, current version 1.0.0) 

However , when I run the python file again, I get an image not found error. When you run otool -L again, the result shows that the file path has returned again.

 /Users/username/.python-eggs/MySQL_python-1.2.5-py2.7-macosx-10.5-x86_64.egg-tmp/_mysql.so: libssl.1.0.0.dylib (compatibility version 1.0.0, current version 1.0.0) 

This way it changes to the correct location until I run the python file and it goes back to what it was before.

Why is this happening? Is there something I can do to support what I changed it to?

+5
source share
1 answer

So, I found that I should work with the libssl.1.0.0.dylib file in /usr/lib , and not with the file mentioned in the error, which was Users/$USERNAME/.python-eggs/MySQL_python-1.2.5-py2.7-macosx-10.5-x86_64.egg-tmp/_mysql.so in my case.

I created a symlink that should be referenced by libssl.1.0.0.dylib , ( /Users/$USERNAME/anaconda/lib/ for me) using

sudo ln -s /Users/$USERNAME/anaconda/lib/libssl.1.0.0.dylib /usr/lib/libssl.1.0.0.dylib

and, as soon as this is done, the same goes for libcrypto.1.0.0.dylib , since it threw the same error.

sudo ln -s /Users/$USERNAME/anaconda/lib/libcrypto.1.0.0.dylib /usr/lib/libcrypto.1.0.0.dylib

As a note, when listing files in /usr/bin the two are listed as libss.dylib and libcrypto.dylib .

+6
source

Source: https://habr.com/ru/post/1201481/


All Articles