Library (dylib) not loaded - image not found - Python IDE

强颜欢笑 提交于 2019-12-02 01:13:07
Maciej Gaca

Found the solution!

Basically I needed to create symbolic links to every dylib that appeared in the error, examples below:

sudo ln -s /Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/savReaderWriter/spssio/macos/libicudata48.1.dylib /usr/local/lib/libicudata48.1.dylib
sudo ln -s /Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/savReaderWriter/spssio/macos/libicui18n48.1.dylib /usr/local/lib/libicui18n48.1.dylib
sudo ln -s /Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/savReaderWriter/spssio/macos/libspssdio.dylib /usr/local/lib/libspssdio.dylib
sudo ln -s /Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/savReaderWriter/spssio/macos/libzlib123spss.dylib /usr/local/lib/libzlib123spss.dylib

So theoretically speaking:

sudo ln -s /path/to/original /path/to/symbolic/link

Regards,

MG

I'll add an answer to this question just to make it more generalizable. Would have preferred a comment but don't have the rep! While Maciej is entirely correct, and his answer helped me find my problem, savReaderWriter has since been updated. As of version 3.4.2 there are now 6 .dlyb files to be copied over.

Once you have your path to your folder (path is location of your error message), make sure to list ( ls in a terminal window) all files within that folder before creating your symlinks. Then create symlinks for each .dylib

Thanks again to Maciej for the great answer!

I am not a Mac person, but are you really using Python 3.6? Does the savReaderWriter support that version? I doubt that the I/o module it uses is built for that version.

If this works via Terminal but not an IDE, check that the Python search paths are the same.

For anyone else who is lazy:

ls /Users/your_user/anaconda/envs/quattro8/lib/python2.7/site-packages/savReaderWriter/spssio/macos/ | xargs -I {} sudo ln -s /Users/your_user/anaconda/envs/quattro8/lib/python2.7/site-packages/savReaderWriter/spssio/macos/{} /usr/local/lib/{}

This links all packages in that repo

You can also specify the path to the libraries within PyCharm, which eliminates the need to create the symbolic links:

From the menubar click "Run" -> "Edit Configurations". In the left pane select the configuration for your python script (usually PyCharm creates a configuration for each .py-file). Insert the path to the libraries (shown in the error message) into "Environment Variables".

Example: DYLD_LIBRARY_PATH=/Users/username/miniconda3/envs/savreader/lib/python3.6/site-packages/savReaderWriter/spssio/macos;

Screenshot of PyCharm Run Configuration

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!