mac 安装 R packages 报错:fatal error

2019-07-30  本文已影响0人  11的雾

之前有一篇文章讲了一键安装R的方法conda install R
今天在安装R package的时候出现了问题,首先我的电脑系统是macOS Mojave,也正常安装了Rstudio,可以用,但是在终端terminal,想安装个命令行版本的。
R装好后是3.6的版本,

$ R

R version 3.6.0 (2019-04-26) -- "Planting of a Tree"
Copyright (C) 2019 The R Foundation for Statistical Computing
Platform: x86_64-apple-darwin13.4.0 (64-bit)

R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under certain conditions.
Type 'license()' or 'licence()' for distribution details.

  Natural language support but running in an English locale

R is a collaborative project with many contributors.
Type 'contributors()' for more information and
'citation()' on how to cite R or R packages in publications.

Type 'demo()' for some demos, 'help()' for on-line help, or
'help.start()' for an HTML browser interface to help.
Type 'q()' to quit R.

然后看一下ggplot2有没有安装(肯定没有安装啦,因为刚装的R)

> library(ggplot2)
Error in library(ggplot2) : there is no package called ‘ggplot2’

一键安装ggplot2

install.packages("ggplot2")
选择了一个镜像,
开始下载各种依赖包,
到最后报错出现了
* installing *source* package ‘backports’ ...
** package ‘backports’ successfully unpacked and MD5 sums checked
** using staged installation
** libs
x86_64-apple-darwin13.4.0-clang -I"/Users/shiyidu/miniconda3/lib/R/include" -DNDEBUG   -D_FORTIFY_SOURCE=2 -mmacosx-version-min=10.9  -I/Users/shiyidu/miniconda3/include  -fPIC  -march=core2 -mtune=haswell -mssse3 -ftree-vectorize -fPIC -fPIE -fstack-protector-strong -O2 -pipe -I/Users/shiyidu/miniconda3/include -fdebug-prefix-map=/Users/builder/ktietz/conda/conda-bld/r-base_1557826964646/work=/usr/local/src/conda/r-base-3.6.0 -fdebug-prefix-map=/Users/shiyidu/miniconda3=/usr/local/src/conda-prefix  -c dotsElt.c -o dotsElt.o
In file included from dotsElt.c:1:
/Users/shiyidu/miniconda3/lib/R/include/R.h:55:11: fatal error: 'stdlib.h' file not found
# include <stdlib.h> /* Not used by R itself, but widely assumed in packages */
          ^~~~~~~~~~
1 error generated.
make: *** [/Users/shiyidu/miniconda3/lib/R/etc/Makeconf:168: dotsElt.o] Error 1
ERROR: compilation failed for package ‘backports’
* removing ‘/Users/shiyidu/miniconda3/lib/R/library/backports’

一顿搜索,在网上找到了同样的小伙伴,暗自幸喜,

image.png
按照这个方法应该也可以修复,
因为我之前也安装了xcode,所以没有按照他的方法而是直接安装:
open /Library/Developer/CommandLineTools/Packages/macOS_SDK_headers_for_macOS_10.14.pkg
安装完成后再去安装ggplot2,就没有任何报错啦。开心,终于解决了。
上一篇下一篇

猜你喜欢

热点阅读