[英]include cairo R on a mac
I'm trying to use 'Cairo' package in Rstudio, using the command install.packages('Cairo')
and it goes through with no problem. 我正在尝试使用命令
install.packages('Cairo')
在Rstudio中使用'Cairo'包,它没有问题。 I get this message- 我收到这条消息 -
The downloaded binary packages are in
/var/folders/xn/c1nj85gx62b89876s15sbv9h0000gn/T//RtmpK9JM0l/downloaded_packages
The package appears in the packages list, but when I try to include the package using library(Cairo)
or library('Cairo')
I get this error mesage- 包出现在包列表中,但是当我尝试使用
library(Cairo)
或library('Cairo')
包含包时,我得到此错误信息 -
Error : .onLoad failed in loadNamespace() for 'Cairo', details:
call: dyn.load(file, DLLpath = DLLpath, ...)
error: unable to load shared object '/Library/Frameworks/R.framework/Versions/3.3/Resources/library/Cairo/libs/Cairo.so':
dlopen(/Library/Frameworks/R.framework/Versions/3.3/Resources/library/Cairo/libs/Cairo.so, 6): Library not loaded: /opt/X11/lib/libXrender.1.dylib
Referenced from: /Library/Frameworks/R.framework/Versions/3.3/Resources/library/Cairo/libs/Cairo.so
Reason: image not found
Error: package or namespace load failed for ‘Cairo’
sessionInfo()
R version 3.3.1 (2016-06-21)
Platform: x86_64-apple-darwin13.4.0 (64-bit)
Running under: OS X 10.11.6 (El Capitan)
locale:
[1] he_IL.UTF-8/he_IL.UTF-8/he_IL.UTF-8/C/he_IL.UTF-8/he_IL.UTF-8
attached base packages:
[1] stats4 parallel stats graphics grDevices utils datasets methods
[9] base
other attached packages:
[1] GenomicRanges_1.24.2 GenomeInfoDb_1.8.3 IRanges_2.6.1
[4] S4Vectors_0.10.2 ggbio_1.20.2 BiocGenerics_0.18.0
[7] ggplot2_2.1.0 BiocInstaller_1.22.3 shiny_0.13.2
I'm not sure why is this happening, any help? 我不确定为什么会这样,有什么帮助吗? Thanks!
谢谢!
You should download X11 for Mac, which is called XQuartz. 您应该下载X11 for Mac,名为XQuartz。 It doesn't ship with OS X any more, so you have to download it separately from: https://www.xquartz.org/
它不再附带OS X,因此您必须单独下载: https : //www.xquartz.org/
For anyone for whom installing XQuartz did not fix the problem: 对于安装XQuartz并未解决问题的任何人:
Check the part of the error message that begins with "Library not loaded: ...". 检查以“Library not loaded:...”开头的错误消息部分。 Eg, 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. 这是关于XQuartz的线索。
In my case, however, it specified that libjpeg
was not loaded, like this: 但是,在我的情况下,它指定没有加载
libjpeg
,如下所示:
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:
然后,我必须为libtiff做同样的事情:
brew unlink libtiff; brew reinstall libtiff
After fixing both of those libraries, running install.packages("Cairo")
worked. 修复这两个库后,运行
install.packages("Cairo")
工作。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.