include cairo R on a mac

前端 未结 2 1893
野性不改
野性不改 2020-12-16 15:29

I\'m trying to use \'Cairo\' package in Rstudio, using the command install.packages(\'Cairo\') and it goes through with no problem. I get this message-

<
2条回答
  •  醉梦人生
    2020-12-16 16:27

    For anyone for whom installing XQuartz did not fix the problem:

    Check the part of the error message that begins with "Library not loaded: ...". E.g., in the user's question, the error message contains this line:

    dlopen(/Library/Frameworks/R.framework/Versions/3.3/Resources/library/Cairo/libs/Cairo.so, 6): Library not loaded: /opt/X11/lib/libXrender.1.dylib
    

    Note this part:

    Library not loaded: /opt/X11/lib/libXrender.1.dylib
    

    That is the part that clues us in about XQuartz.

    In my case, however, it specified that libjpeg was not loaded, like this:

    Error: package or namespace load failed for ‘Cairo’:
     .onLoad failed in loadNamespace() for 'Cairo', details:
      call: dyn.load(file, DLLpath = DLLpath, ...)
      error: unable to load shared object '/usr/local/lib/R/3.5/site-library/Cairo/libs/Cairo.so':
      dlopen(/usr/local/lib/R/3.5/site-library/Cairo/libs/Cairo.so, 6): Library not loaded: /usr/local/opt/jpeg/lib/libjpeg.9.dylib
      Referenced from: /usr/local/lib/R/3.5/site-library/Cairo/libs/Cairo.so
      Reason: image not found
    Error: loading failed
    

    Note this part:

    Library not loaded: /usr/local/opt/jpeg/lib/libjpeg.9.dylib
    

    To fix this, I had to run

    brew unlink libjpeg; brew reinstall libjpeg
    

    to get it working. I then had to do the same thing for libtiff:

    brew unlink libtiff; brew reinstall libtiff
    

    After fixing both of those libraries, running install.packages("Cairo") worked.

提交回复
热议问题