truncated path to libRblas.dylib on OS X Lion

Issue #78 resolved
telliott99 created an issue

It appears that the path that _rinterface.so specifies to load libRblas.dylib is incorrect (it lacks the prefix) on my system---OS X Lion, R version 2.13.1 Patched, Python 2.7.1, rpy2 installed by easy_install as rpy2-2.2.2dev_20110817-py2.7-macosx-10.7-intel.egg.

python -c "from rpy2 import robjects" Traceback (most recent call last): File "<string>", line 1, in <module> File "/Library/Python/2.7/site-packages/rpy2-2.2.2dev_20110817-py2.7-macosx-10.7-intel.egg/rpy2/robjects/init.py", line 14, in <module> import rpy2.rinterface as rinterface File "/Library/Python/2.7/site-packages/rpy2-2.2.2dev_20110817-py2.7-macosx-10.7-intel.egg/rpy2/rinterface/init.py", line 78, in <module> from rpy2.rinterface._rinterface import * ImportError: dlopen(/Library/Python/2.7/site-packages/rpy2-2.2.2dev_20110817-py2.7-macosx-10.7-intel.egg/rpy2/rinterface/_rinterface.so, 2): Library not loaded: libRblas.dylib Referenced from: /Library/Python/2.7/site-packages/rpy2-2.2.2dev_20110817-py2.7-macosx-10.7-intel.egg/rpy2/rinterface/_rinterface.so Reason: image not found

otool -L /Library/Python/2.7/site-packages/rpy2-2.2.2dev_20110817-py2.7-macosx-10.7-intel.egg/rpy2/rinterface/_rinterface.so /Library/Python/2.7/site-packages/rpy2-2.2.2dev_20110817-py2.7-macosx-10.7-intel.egg/rpy2/rinterface/_rinterface.so: /Library/Frameworks/R.framework/Versions/2.13/Resources/lib/libR.dylib (compatibility version 2.13.0, current version 2.13.1) libRblas.dylib (compatibility version 0.0.0, current version 0.0.0) /Library/Frameworks/R.framework/Versions/2.13/Resources/lib/libRlapack.dylib (compatibility version 2.13.0, current version 2.13.1) /usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 159.0.0)

I can fix it with a sym link from the directory I'm working in, but what's a good way? Should I try installing rpy2 with distutils and setup.py? Thanks.

Comments (15)

  1. Laurent Gautier

    Thanks for the report, but unfortunately I currently do not have access to OS X Lion.

    • Do you experience the problem with a fresh install of rpy2 (or is this the result of upgrading a Mac OS install to Lion) ?
    • Did you compile R yourself or do you use precompiled binaries ? If the later case, where did you fetch them from ?
  2. Former user Account Deleted

    Running same R as @telliot99. No luck installing using disutils. Path to rpy_device.so is truncated as telliot99 reported (compatibility version notes removed for clarity). After building and installing:

    In [1]: import rpy2.robjects as robjects
    ---------------------------------------------------------------------------
    ImportError                               Traceback (most recent call last)
    /Users/bcf/<ipython-input-1-645b0f765c67> in <module>()
    ----> 1 import rpy2.robjects as robjects
    
    /usr/local/Cellar/python/2.7.2/lib/python2.7/site-packages/rpy2/robjects/__init__.py in <module>()
         12 import array
         13 import itertools
    ---> 14 import rpy2.rinterface as rinterface
         15 import rpy2.rlike.container as rlc
         16 
    
    /usr/local/Cellar/python/2.7.2/lib/python2.7/site-packages/rpy2/rinterface/__init__.py in <module>()
         76 
         77 
    ---> 78 from rpy2.rinterface._rinterface import *
         79 
         80 
    
    ImportError: dlopen(/usr/local/Cellar/python/2.7.2/lib/python2.7/site-packages/rpy2/rinterface/_rinterface.so, 2): Library not loaded: libRblas.dylib
      Referenced from: /usr/local/Cellar/python/2.7.2/lib/python2.7/site-packages/rpy2/rinterface/_rinterface.so
      Reason: image not found
    

    check paths:

    % otool -L build/lib.macosx-10.4-x86_64-2.7/rpy2/rinterface/rpy_device.so
      
    build/lib.macosx-10.4-x86_64-2.7/rpy2/rinterface/rpy_device.so:
    	/Library/Frameworks/R.framework/Versions/2.13/Resources/lib/libR.dylib
    	libRblas.dylib
    	/Library/Frameworks/R.framework/Versions/2.13/Resources/lib/libRlapack.dylib
    	/usr/lib/libgcc_s.1.dylib
    	/usr/lib/libSystem.B.dylib
    

    Here's what it looks like in /Library/Frameworks/R.framework/Versions/2.13/Resources/lib/libRblas.dylib:

    ls -al /Library/Frameworks/R.framework/Versions/2.13/Resources/lib/                                 ~/Src/rpy2-2.2.4  
    total 47304
    drwxrwxr-x  16 root  admin      544 Sep 10 10:20 .
    drwxrwxr-x  19 root  admin      646 Sep 10 10:19 ..
    drwxrwxr-x   5 root  admin      170 Sep 10 10:19 i386
    -rwxrwxr-x   1 root  admin  9783232 Sep  9 21:33 libR.dylib
    drwxrwxr-x   3 root  admin      102 Sep  9 21:33 libR.dylib.dSYM
    -rwxrwxr-x   1 root  admin   539928 Sep  9 21:33 libRblas.0.dylib
    lrwxr-xr-x   1 root  admin       21 Sep 10 10:20 libRblas.dylib -> libRblas.vecLib.dylib
    drwxrwxr-x   3 root  admin      102 Sep  9 21:33 libRblas.dylib.dSYM
    -rwxrwxr-x   1 root  admin    65981 Sep  9 21:33 libRblas.vecLib.dylib
    -rwxrwxr-x   1 root  admin  3980136 Sep  9 21:33 libRlapack.dylib
    drwxrwxr-x   3 root  admin      102 Sep  9 21:33 libRlapack.dylib.dSYM
    -rwxrwxr-x   1 root  admin   736903 Sep  9 21:33 libgcc_s.1.dylib
    -rwxrwxr-x   1 root  admin  8094839 Sep  9 21:33 libgfortran.2.dylib
    -rwxrwxr-x   1 root  admin   996788 Sep  9 21:33 libreadline.5.2.dylib
    lrwxr-xr-x   1 root  admin       21 Sep 10 10:19 libreadline.dylib -> libreadline.5.2.dylib
    drwxrwxr-x   5 root  admin      170 Sep 10 10:19 x86_64
    
  3. Brant Faircloth

    To quickly follow-up on my previous comment (after creating account), if you change the symlink in /Library/Frameworks/R.framework/Versions/2.13/Resources/lib/ to the non-vecLib version

    cd /Library/Frameworks/R.framework/Versions/2.13/Resources/lib/
    rm libRblas.dylib
    ln -s libRblas.0.dylib libRblas.dylib
    

    and then build the 2.2.4 source

    cd ~/Src/rpy2-2.2.4
    python setup.py build
    

    then check the shared object:

    otool -L build/lib.macosx-10.4-x86_64-2.7/rpy2/rinterface/_rinterface.so
    
    build/lib.macosx-10.4-x86_64-2.7/rpy2/rinterface/_rinterface.so:
    	/Library/Frameworks/R.framework/Versions/2.13/Resources/lib/libR.dylib
    	/Library/Frameworks/R.framework/Versions/2.13/Resources/lib/libRblas.dylib
    	/Library/Frameworks/R.framework/Versions/2.13/Resources/lib/libRlapack.dylib
    	/usr/lib/libgcc_s.1.dylib
    	/usr/lib/libSystem.B.dylib
    

    everything is happy again. Then, if you install python setup.py install, everything works as it should, so it looks like the veclib blas library is the culprit. It causes other problems, too (https://stat.ethz.ch/pipermail/r-sig-mac/2011-January/007956.html):

    In [1]: import rpy2.robjects as robjects
    
    In [2]: 
    

    Note: in theory and in practice, on certain archs, this change will result in slower computations.

  4. Laurent Gautier

    This is rather odd.

    Anything in the console dump during the compilation of rpy2 that would give a hint ?

  5. Brant Faircloth

    Does not appear to be - I don't see a problem in the output and the compile flags look fine (i switched the link back to veclib for this test):

    running build
    running build_py
    creating build
    creating build/lib.macosx-10.4-x86_64-2.7
    creating build/lib.macosx-10.4-x86_64-2.7/rpy2
    copying ./rpy/__init__.py -> build/lib.macosx-10.4-x86_64-2.7/rpy2
    copying ./rpy/rpy_classic.py -> build/lib.macosx-10.4-x86_64-2.7/rpy2
    copying ./rpy/tests.py -> build/lib.macosx-10.4-x86_64-2.7/rpy2
    copying ./rpy/tests_rpy_classic.py -> build/lib.macosx-10.4-x86_64-2.7/rpy2
    creating build/lib.macosx-10.4-x86_64-2.7/rpy2/rlike
    copying ./rpy/rlike/__init__.py -> build/lib.macosx-10.4-x86_64-2.7/rpy2/rlike
    copying ./rpy/rlike/container.py -> build/lib.macosx-10.4-x86_64-2.7/rpy2/rlike
    copying ./rpy/rlike/functional.py -> build/lib.macosx-10.4-x86_64-2.7/rpy2/rlike
    copying ./rpy/rlike/indexing.py -> build/lib.macosx-10.4-x86_64-2.7/rpy2/rlike
    creating build/lib.macosx-10.4-x86_64-2.7/rpy2/rlike/tests
    copying ./rpy/rlike/tests/__init__.py -> build/lib.macosx-10.4-x86_64-2.7/rpy2/rlike/tests
    copying ./rpy/rlike/tests/test_container.py -> build/lib.macosx-10.4-x86_64-2.7/rpy2/rlike/tests
    copying ./rpy/rlike/tests/test_functional.py -> build/lib.macosx-10.4-x86_64-2.7/rpy2/rlike/tests
    copying ./rpy/rlike/tests/test_indexing.py -> build/lib.macosx-10.4-x86_64-2.7/rpy2/rlike/tests
    creating build/lib.macosx-10.4-x86_64-2.7/rpy2/rinterface
    copying ./rpy/rinterface/__init__.py -> build/lib.macosx-10.4-x86_64-2.7/rpy2/rinterface
    creating build/lib.macosx-10.4-x86_64-2.7/rpy2/rinterface/tests
    copying ./rpy/rinterface/tests/__init__.py -> build/lib.macosx-10.4-x86_64-2.7/rpy2/rinterface/tests
    copying ./rpy/rinterface/tests/test_Device.py -> build/lib.macosx-10.4-x86_64-2.7/rpy2/rinterface/tests
    copying ./rpy/rinterface/tests/test_EmbeddedR.py -> build/lib.macosx-10.4-x86_64-2.7/rpy2/rinterface/tests
    copying ./rpy/rinterface/tests/test_Sexp.py -> build/lib.macosx-10.4-x86_64-2.7/rpy2/rinterface/tests
    copying ./rpy/rinterface/tests/test_SexpClosure.py -> build/lib.macosx-10.4-x86_64-2.7/rpy2/rinterface/tests
    copying ./rpy/rinterface/tests/test_SexpEnvironment.py -> build/lib.macosx-10.4-x86_64-2.7/rpy2/rinterface/tests
    copying ./rpy/rinterface/tests/test_SexpExtPtr.py -> build/lib.macosx-10.4-x86_64-2.7/rpy2/rinterface/tests
    copying ./rpy/rinterface/tests/test_SexpVector.py -> build/lib.macosx-10.4-x86_64-2.7/rpy2/rinterface/tests
    copying ./rpy/rinterface/tests/test_SexpVectorNumeric.py -> build/lib.macosx-10.4-x86_64-2.7/rpy2/rinterface/tests
    creating build/lib.macosx-10.4-x86_64-2.7/rpy2/robjects
    copying ./rpy/robjects/__init__.py -> build/lib.macosx-10.4-x86_64-2.7/rpy2/robjects
    copying ./rpy/robjects/constants.py -> build/lib.macosx-10.4-x86_64-2.7/rpy2/robjects
    copying ./rpy/robjects/conversion.py -> build/lib.macosx-10.4-x86_64-2.7/rpy2/robjects
    copying ./rpy/robjects/environments.py -> build/lib.macosx-10.4-x86_64-2.7/rpy2/robjects
    copying ./rpy/robjects/functions.py -> build/lib.macosx-10.4-x86_64-2.7/rpy2/robjects
    copying ./rpy/robjects/help.py -> build/lib.macosx-10.4-x86_64-2.7/rpy2/robjects
    copying ./rpy/robjects/language.py -> build/lib.macosx-10.4-x86_64-2.7/rpy2/robjects
    copying ./rpy/robjects/methods.py -> build/lib.macosx-10.4-x86_64-2.7/rpy2/robjects
    copying ./rpy/robjects/numpy2ri.py -> build/lib.macosx-10.4-x86_64-2.7/rpy2/robjects
    copying ./rpy/robjects/packages.py -> build/lib.macosx-10.4-x86_64-2.7/rpy2/robjects
    copying ./rpy/robjects/robject.py -> build/lib.macosx-10.4-x86_64-2.7/rpy2/robjects
    copying ./rpy/robjects/vectors.py -> build/lib.macosx-10.4-x86_64-2.7/rpy2/robjects
    creating build/lib.macosx-10.4-x86_64-2.7/rpy2/robjects/tests
    copying ./rpy/robjects/tests/__init__.py -> build/lib.macosx-10.4-x86_64-2.7/rpy2/robjects/tests
    copying ./rpy/robjects/tests/testArray.py -> build/lib.macosx-10.4-x86_64-2.7/rpy2/robjects/tests
    copying ./rpy/robjects/tests/testDataFrame.py -> build/lib.macosx-10.4-x86_64-2.7/rpy2/robjects/tests
    copying ./rpy/robjects/tests/testEnvironment.py -> build/lib.macosx-10.4-x86_64-2.7/rpy2/robjects/tests
    copying ./rpy/robjects/tests/testFormula.py -> build/lib.macosx-10.4-x86_64-2.7/rpy2/robjects/tests
    copying ./rpy/robjects/tests/testFunction.py -> build/lib.macosx-10.4-x86_64-2.7/rpy2/robjects/tests
    copying ./rpy/robjects/tests/testHelp.py -> build/lib.macosx-10.4-x86_64-2.7/rpy2/robjects/tests
    copying ./rpy/robjects/tests/testLanguage.py -> build/lib.macosx-10.4-x86_64-2.7/rpy2/robjects/tests
    copying ./rpy/robjects/tests/testMethods.py -> build/lib.macosx-10.4-x86_64-2.7/rpy2/robjects/tests
    copying ./rpy/robjects/tests/testNumpyConversions.py -> build/lib.macosx-10.4-x86_64-2.7/rpy2/robjects/tests
    copying ./rpy/robjects/tests/testPackages.py -> build/lib.macosx-10.4-x86_64-2.7/rpy2/robjects/tests
    copying ./rpy/robjects/tests/testRObject.py -> build/lib.macosx-10.4-x86_64-2.7/rpy2/robjects/tests
    copying ./rpy/robjects/tests/testRobjects.py -> build/lib.macosx-10.4-x86_64-2.7/rpy2/robjects/tests
    copying ./rpy/robjects/tests/testVector.py -> build/lib.macosx-10.4-x86_64-2.7/rpy2/robjects/tests
    creating build/lib.macosx-10.4-x86_64-2.7/rpy2/robjects/lib
    copying ./rpy/robjects/lib/__init__.py -> build/lib.macosx-10.4-x86_64-2.7/rpy2/robjects/lib
    copying ./rpy/robjects/lib/ggplot2.py -> build/lib.macosx-10.4-x86_64-2.7/rpy2/robjects/lib
    copying ./rpy/robjects/lib/grid.py -> build/lib.macosx-10.4-x86_64-2.7/rpy2/robjects/lib
    creating build/lib.macosx-10.4-x86_64-2.7/rpy2/interactive
    copying ./rpy/interactive/__init__.py -> build/lib.macosx-10.4-x86_64-2.7/rpy2/interactive
    copying ./rpy/interactive/process_revents.py -> build/lib.macosx-10.4-x86_64-2.7/rpy2/interactive
    creating build/lib.macosx-10.4-x86_64-2.7/rpy2/interactive/tests
    copying ./rpy/interactive/tests/__init__.py -> build/lib.macosx-10.4-x86_64-2.7/rpy2/interactive/tests
    running build_ext
    Configuration for R as a library:
      include_dirs: ('/Library/Frameworks/R.framework/Resources/include', '/Library/Frameworks/R.framework/Resources/include/x86_64')
      libraries: ('Rblas', 'Rlapack')
      library_dirs: ('/Library/Frameworks/R.framework/Resources/lib/x86_64',)
      extra_link_args: ('-framework R', '-F/Library/Frameworks/R.framework/..')
     # OSX-specific (included in extra_link_args)
      framework_dirs: ('-F/Library/Frameworks/R.framework/..',)
      frameworks: ('-framework R',)
    building 'rpy2.rinterface._rinterface' extension
    creating build/temp.macosx-10.4-x86_64-2.7
    creating build/temp.macosx-10.4-x86_64-2.7/rpy
    creating build/temp.macosx-10.4-x86_64-2.7/rpy/rinterface
    /usr/bin/cc -fno-strict-aliasing -O3 -march=core2 -msse4.1 -w -pipe -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -DR_INTERFACE_PTRS=1 -DHAVE_POSIX_SIGJMP=1 -DCSTACK_DEFNS=1 -DRIF_HAS_RSIGHAND=1 -I./rpy/rinterface -I/usr/local/Cellar/python/2.7.2/include/python2.7 -I/Library/Frameworks/R.framework/Resources/include -I/Library/Frameworks/R.framework/Resources/include/x86_64 -c ./rpy/rinterface/_rinterface.c -o build/temp.macosx-10.4-x86_64-2.7/./rpy/rinterface/_rinterface.o
    /usr/bin/cc -bundle -undefined dynamic_lookup -L/usr/local/Cellar/readline/6.2.1/lib build/temp.macosx-10.4-x86_64-2.7/./rpy/rinterface/_rinterface.o -L/Library/Frameworks/R.framework/Resources/lib/x86_64 -L/Library/Frameworks/R.framework/Resources/modules -lR -lRblas -lRlapack -o build/lib.macosx-10.4-x86_64-2.7/rpy2/rinterface/_rinterface.so
    building 'rpy2.rinterface.rpy_device' extension
    /usr/bin/cc -fno-strict-aliasing -O3 -march=core2 -msse4.1 -w -pipe -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -DR_INTERFACE_PTRS=1 -DHAVE_POSIX_SIGJMP=1 -DCSTACK_DEFNS=1 -DRIF_HAS_RSIGHAND=1 -Irpy/rinterface -I/usr/local/Cellar/python/2.7.2/include/python2.7 -I/Library/Frameworks/R.framework/Resources/include -I/Library/Frameworks/R.framework/Resources/include/x86_64 -c rpy/rinterface/rpy_device.c -o build/temp.macosx-10.4-x86_64-2.7/rpy/rinterface/rpy_device.o
    /usr/bin/cc -bundle -undefined dynamic_lookup -L/usr/local/Cellar/readline/6.2.1/lib build/temp.macosx-10.4-x86_64-2.7/rpy/rinterface/rpy_device.o -L/Library/Frameworks/R.framework/Resources/lib/x86_64 -L/Library/Frameworks/R.framework/Resources/modules -lR -lRblas -lRlapack -o build/lib.macosx-10.4-x86_64-2.7/rpy2/rinterface/rpy_device.so
    

    ensure path is truncated again:

    otool -L build/lib.macosx-10.4-x86_64-2.7/rpy2/rinterface/_rinterface.so
    build/lib.macosx-10.4-x86_64-2.7/rpy2/rinterface/_rinterface.so:
    	/Library/Frameworks/R.framework/Versions/2.13/Resources/lib/libR.dylib
    	libRblas.dylib
    	/Library/Frameworks/R.framework/Versions/2.13/Resources/lib/libRlapack.dylib
    	/usr/lib/libgcc_s.1.dylib
    	/usr/lib/libSystem.B.dylib
    

    update:check diff of "good" and "bad" builds (after renabling link to non-veclib version):

    diff rpy2-2.2.4-build.noveclib.dump.txt rpy2-2.2.4-build.veclib.dump.txt
    <no output>
    
  6. Former user Account Deleted

    I had the same issue. But the new Mac build of R (2.13.2) and reinstalling rpy2 fixes it.

  7. Brant Faircloth

    In the 2.14 build of R (osx), there is no longer a problem building, installing or importing rpy2. It appears that the package maintainers for the osx build of R have changed the symlink, as above:

    ls -al /Library/Frameworks/R.framework/Versions/2.14/Resources/lib/                                                                                                                                         
    total 47528
    drwxrwxr-x  16 root  admin      544 Nov  1 15:56 .
    drwxrwxr-x  19 root  admin      646 Nov  1 15:55 ..
    drwxrwxr-x   5 root  admin      170 Nov  1 15:55 i386
    -rwxrwxr-x   1 root  admin  9896624 Oct 31 13:59 libR.dylib
    drwxrwxr-x   3 root  admin      102 Oct 31 13:59 libR.dylib.dSYM
    -rwxrwxr-x   1 root  admin   539904 Oct 31 13:59 libRblas.0.dylib
    lrwxr-xr-x   1 root  admin       16 Nov  1 15:55 libRblas.dylib -> libRblas.0.dylib
    drwxrwxr-x   3 root  admin      102 Oct 31 13:59 libRblas.dylib.dSYM
    -rwxrwxr-x   1 root  admin    65981 Oct 31 13:59 libRblas.vecLib.dylib
    -rwxrwxr-x   1 root  admin  3980060 Oct 31 13:59 libRlapack.dylib
    drwxrwxr-x   3 root  admin      102 Oct 31 13:59 libRlapack.dylib.dSYM
    -rwxrwxr-x   1 root  admin   736903 Oct 31 13:59 libgcc_s.1.dylib
    -rwxrwxr-x   1 root  admin  8094839 Oct 31 13:59 libgfortran.2.dylib
    -rwxrwxr-x   1 root  admin   996788 Oct 31 13:59 libreadline.5.2.dylib
    lrwxr-xr-x   1 root  admin       21 Nov  1 15:55 libreadline.dylib -> libreadline.5.2.dylib
    drwxrwxr-x   5 root  admin      170 Nov  1 15:55 x86_64
    
    otool -L build/lib.macosx-10.4-x86_64-2.7/rpy2/rinterface/_rinterface.so                                                                                                                                    ~/Src/rpy2-2.2.3  
    build/lib.macosx-10.4-x86_64-2.7/rpy2/rinterface/_rinterface.so:
    	/Library/Frameworks/R.framework/Versions/2.14/Resources/lib/libR.dylib
    	/Library/Frameworks/R.framework/Versions/2.14/Resources/lib/libRblas.dylib
    	/Library/Frameworks/R.framework/Versions/2.14/Resources/lib/libRlapack.dylib
    	/usr/lib/libgcc_s.1.dylib
    	/usr/lib/libSystem.B.dylib
    
  8. Log in to comment