SavWriter - macOS Error - libicuuc48.1.dylib - Reason: image not found

Issue #62 new
Maciej Gaca created an issue

Hello,

Mac user here.

I'm trying to export data directly from Pandas DataFrame into a .sav file. Sadly I can't get it to work due to error:

Traceback (most recent call last):
  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/IPython/core/interactiveshell.py", line 2847, in run_code
    exec(code_obj, self.user_global_ns, self.user_ns)
  File "<ipython-input-25-2a483c47279f>", line 7, in <module>
    with savReaderWriter.SavWriter(savFileName, varNames, varTypes, ioUtf8=True) as writer:
  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/savReaderWriter/savWriter.py", line 198, in __init__
    super(Header, self).__init__(savFileName, ioUtf8, ioLocale)
  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/savReaderWriter/generic.py", line 29, in __init__
    self.spssio = self.loadLibrary()
  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/savReaderWriter/generic.py", line 117, in loadLibrary
    spssio = self._loadLibs("macos")
  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/savReaderWriter/generic.py", line 89, in _loadLibs
    return [load(os.path.join(path, lib)) for lib in libs][-1]
  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/savReaderWriter/generic.py", line 89, in <listcomp>
    return [load(os.path.join(path, lib)) for lib in libs][-1]
  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/ctypes/__init__.py", line 348, in __init__
    self._handle = _dlopen(self._name, mode)
OSError: dlopen(/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/savReaderWriter/spssio/macos/libicuuc48.1.dylib, 6): Library not loaded: @executable_path/../lib/libicudata48.1.dylib
  Referenced from: /Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/savReaderWriter/spssio/macos/libicuuc48.1.dylib
  Reason: image not found

I already added following lines to my .bashrc file (as suggested in this thread: https://bitbucket.org/fomcl/savreaderwriter/issues/16/dylibs-on-os-x-ibm-problem):

#!
export DYLD_LIBRARY_PATH=/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/savReaderWriter/spssio/macos
export LC_ALL=en_US.UTF-8

That sadly does not work for me. So far the only way I got the whole thing to work was:

  1. Running the export commands in the terminal.
  2. Opening python in the terminal.
  3. Running the savwriter code.

Due to obvious reasons I'd rather stick to my IDE, therefore I would be very glad for any ideas on how to fix this issue.

Regards,

Mat Gaca

Comments (8)

  1. Albert-Jan Roskam repo owner

    Hi Mat,

    You can add those lines to .bash_profile instead. According to this this page, .bashrc works differently in Mac OS compared to Linux. You can edit this manually, or run the code below. Warning: use 2 (two) >> signs . Not sure if you need to restart your IDE after that. Let me know if that works!

    echo 'export DYLD_LIBRARY_PATH=/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/savReaderWriter/spssio/macos'  >> ~/.bash_profile
    echo 'export LC_ALL=en_US.UTF-8'  >> ~/.bash_profile
    

    Best wishes, Albert-Jan

  2. Maciej Gaca reporter

    Dear Albert-Jan,

    Thank you for your swift answer. Did as you suggested and while there is some progress (don't need the export commands in terminal anymore), I'm still getting the same error in my IDE (not that it probably matters but I'm using PyCharm).

    Best regards,

    Mat Gaca

  3. Maciej Gaca reporter

    Dear Albert-Jan,

    Thanks for yet another answer. So far no luck here, but will let you know if I make any progress. This is really strange though - if I run your example code in Python through terminal, it works fine. Same thing through my IDE keeps giving me image not found dylib error.

    Regards,

    MG

  4. Maciej Gaca reporter

    Hey there,

    Finally managed to find a solution. What I needed to do was create a bunch of symbiotic links to all the dylibs that my IDE refused to locate, 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 you can do it like that:

    #!
    sudo ln -s /path/to/original /path/to/symbiotic/link
    

    Regards,

    MG

  5. Prashant Sharma

    Hey there, thanks for posting the solution. Do you know how should we choose /path/to/symbiotic/link?

  6. Matthew Brett

    Sorry, to be more specific, the install names in the archive look like this:

    $ otool -L libspssdio.dylib 
    libspssdio.dylib:
        @executable_path/../lib/libspssdio.dylib (compatibility version 0.0.0, current version 0.0.0)
        @executable_path/../lib/libicuuc48.1.dylib (compatibility version 48.0.0, current version 48.1.0)
        @executable_path/../lib/libicudata48.1.dylib (compatibility version 48.0.0, current version 48.1.0)
        @executable_path/../lib/libicui18n48.1.dylib (compatibility version 48.0.0, current version 48.1.0)
        @executable_path/../lib/libzlib123spss.dylib (compatibility version 0.0.0, current version 0.0.0)
        /usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 111.1.4)
        /usr/lib/libstdc++.6.dylib (compatibility version 7.0.0, current version 7.4.0)
        /usr/lib/libgcc_s.1.dylib (compatibility version 1.0.0, current version 1.0.0)
    

    My script (above), sets them to this form:

    $ otool -L libspssdio.dylib 
    libspssdio.dylib:
        libspssdio.dylib (compatibility version 0.0.0, current version 0.0.0)
        @loader_path/libicuuc48.1.dylib (compatibility version 48.0.0, current version 48.1.0)
        @loader_path/libicudata48.1.dylib (compatibility version 48.0.0, current version 48.1.0)
        @loader_path/libicui18n48.1.dylib (compatibility version 48.0.0, current version 48.1.0)
        @loader_path/libzlib123spss.dylib (compatibility version 0.0.0, current version 0.0.0)
        /usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 111.1.4)
        /usr/lib/libstdc++.6.dylib (compatibility version 7.0.0, current version 7.4.0)
        /usr/lib/libgcc_s.1.dylib (compatibility version 1.0.0, current version 1.0.0)
    
  7. Log in to comment