R for Mac(M1)安装R包辛酸教程 您所在的位置:网站首页 苹果电脑怎么下载rstudio R for Mac(M1)安装R包辛酸教程

R for Mac(M1)安装R包辛酸教程

2024-07-03 01:55| 来源: 网络整理| 查看: 265

欢迎收看hanhan的辛酸血泪史orz

关于R for Mac(M1)安装失败/下载后报错

文章目录 前言1. 非零报错-have no-zero-there is no package-缺包2. 安装失败-install from sources the package-下载源文件3. 关于我尚未解决的问题

前言

鬼迷心窍买了Mac,用着很爽,配置的很痛苦~

我个人觉得很多工程师程序猿应该都觉得,配置是最快乐但也是最痛苦的事情,尤其是在Win教程那么多,我却用Mac的当下。

作为一个正在努力学英语(但是依旧英语白痴)的工程师,看不懂代码,自然就会直接去百度,但是这样最大的问题是什么呢?你不知道真正的问题是什么,可能你搜的有个偏差,搜到你电脑爆炸都没搜出来。

所以在这我好心劝告,看报错吧,看懂了比啥都有用。

备注一句:要我学好英语,可能只有投胎有用了orz

1. 非零报错-have no-zero-there is no package-缺包

我在刚开始最头痛的就是这一点了,我下什么包都这个毛病,真的气死我了!!!我们特意删了个之前好不容易装好的包,来把这个报错弄出来:

> install.packages('VIM') There is a binary version available but the source version is later: binary source needs_compilation VIM 6.1.0 6.1.1 TRUE Do you want to install from sources the package which needs compilation? (Yes/no/cancel) y installing the source package ‘VIM’ trying URL 'https://cran.rstudio.com/src/contrib/VIM_6.1.1.tar.gz' Content type 'application/x-gzip' length 2193653 bytes (2.1 MB) ================================================== downloaded 2.1 MB * installing *source* package ‘VIM’ ... ** package ‘VIM’ successfully unpacked and MD5 sums checked ** using staged installation ** libs clang++ -arch arm64 -std=gnu++14 -I"/Library/Frameworks/R.framework/Resources/include" -DNDEBUG -I'/Library/Frameworks/R.framework/Versions/4.1-arm64/Resources/library/Rcpp/include' -I/opt/R/arm64/include -fPIC -falign-functions=64 -Wall -g -O2 -c RcppExports.cpp -o RcppExports.o clang++ -arch arm64 -std=gnu++14 -I"/Library/Frameworks/R.framework/Resources/include" -DNDEBUG -I'/Library/Frameworks/R.framework/Versions/4.1-arm64/Resources/library/Rcpp/include' -I/opt/R/arm64/include -fPIC -falign-functions=64 -Wall -g -O2 -c gowerD.cpp -o gowerD.o clang++ -arch arm64 -std=gnu++14 -dynamiclib -Wl,-headerpad_max_install_names -undefined dynamic_lookup -single_module -multiply_defined suppress -L/Library/Frameworks/R.framework/Resources/lib -L/opt/R/arm64/lib -o VIM.so RcppExports.o gowerD.o -F/Library/Frameworks/R.framework/.. -framework R -Wl,-framework -Wl,CoreFoundation installing to /Library/Frameworks/R.framework/Versions/4.1-arm64/Resources/library/00LOCK-VIM/00new/VIM/libs ** R ** data *** moving datasets to lazyload DB ** inst ** byte-compile and prepare package for lazy loading Error in loadNamespace(i, c(lib.loc, .libPaths()), versionCheck = vI[[i]]) : there is no package called ‘vctrs’ Calls: ... loadNamespace -> withRestarts -> withOneRestart -> doWithOneRestart Execution halted ERROR: lazy loading failed for package ‘VIM’ * removing ‘/Library/Frameworks/R.framework/Versions/4.1-arm64/Resources/library/VIM’ Warning in install.packages : installation of package ‘VIM’ had non-zero exit status The downloaded source packages are in ‘/private/var/folders/bj/w7w9z5vd3cz7vsrcfr7m0pz80000gn/T/RtmpLJq2I7/downloaded_packages’

所以这个报错究竟是发生甚么事了?我们可以看这几行:

Do you want to install from sources the package which needs compilation? (Yes/no/cancel) y Error in loadNamespace(i, c(lib.loc, .libPaths()), versionCheck = vI[[i]]) : there is no package called ‘vctrs’ Calls: ... loadNamespace -> withRestarts -> withOneRestart -> doWithOneRestart Execution halted Warning in install.packages : installation of package ‘VIM’ had non-zero exit status

在代码中,凭肉眼觉得可能有毛病的信息有这些,我先来讲第三个-非零报错:

其实看这个根本看不懂是啥毛病,但是我就是根据这个去网上搜毛病的,所以我才说要好好看报错

然后再看第二个,报错说我们没有’vctrs’这个包,他这么说我就好办了,你说没有我就装呗:

> install.packages('vctrs') trying URL 'https://cran.rstudio.com/bin/macosx/big-sur-arm64/contrib/4.1/vctrs_0.3.8.tgz' Content type 'application/x-gzip' length 1450121 bytes (1.4 MB) ================================================== downloaded 1.4 MB The downloaded binary packages are in /var/folders/bj/w7w9z5vd3cz7vsrcfr7m0pz80000gn/T//RtmpLJq2I7/downloaded_packages > install.packages('VIM') There is a binary version available but the source version is later: binary source needs_compilation VIM 6.1.0 6.1.1 TRUE Do you want to install from sources the package which needs compilation? (Yes/no/cancel) y installing the source package ‘VIM’ trying URL 'https://cran.rstudio.com/src/contrib/VIM_6.1.1.tar.gz' Content type 'application/x-gzip' length 2193653 bytes (2.1 MB) ================================================== downloaded 2.1 MB * installing *source* package ‘VIM’ ... ** package ‘VIM’ successfully unpacked and MD5 sums checked ** using staged installation ** libs clang++ -arch arm64 -std=gnu++14 -I"/Library/Frameworks/R.framework/Resources/include" -DNDEBUG -I'/Library/Frameworks/R.framework/Versions/4.1-arm64/Resources/library/Rcpp/include' -I/opt/R/arm64/include -fPIC -falign-functions=64 -Wall -g -O2 -c RcppExports.cpp -o RcppExports.o clang++ -arch arm64 -std=gnu++14 -I"/Library/Frameworks/R.framework/Resources/include" -DNDEBUG -I'/Library/Frameworks/R.framework/Versions/4.1-arm64/Resources/library/Rcpp/include' -I/opt/R/arm64/include -fPIC -falign-functions=64 -Wall -g -O2 -c gowerD.cpp -o gowerD.o clang++ -arch arm64 -std=gnu++14 -dynamiclib -Wl,-headerpad_max_install_names -undefined dynamic_lookup -single_module -multiply_defined suppress -L/Library/Frameworks/R.framework/Resources/lib -L/opt/R/arm64/lib -o VIM.so RcppExports.o gowerD.o -F/Library/Frameworks/R.framework/.. -framework R -Wl,-framework -Wl,CoreFoundation installing to /Library/Frameworks/R.framework/Versions/4.1-arm64/Resources/library/00LOCK-VIM/00new/VIM/libs ** R ** data *** moving datasets to lazyload DB ** inst ** byte-compile and prepare package for lazy loading ** help *** installing help indices ** building package indices ** installing vignettes ** testing if installed package can be loaded from temporary location ** checking absolute paths in shared objects and dynamic libraries ** testing if installed package can be loaded from final location ** testing if installed package keeps a record of temporary installation path * DONE (VIM) The downloaded source packages are in ‘/private/var/folders/bj/w7w9z5vd3cz7vsrcfr7m0pz80000gn/T/RtmpLJq2I7/downloaded_packages’

wow,我们装好了,所以其实现在没装好的原因是我们缺包了,我们把包装上就好了。所以看报错很重要

那我们遇到这种问题,把提出来的Error都处理了就好了。

(备注:关于上面的问题,因为我只删除了VIM包和vctrs这两个包,所以只要安装vctrs就可以了,但其实最开始有更多包没装,所以要根据报错一个一个装哦)

但我列出来了都第一条:我们在最开始选择的yes/no/cancel。这个有什么问题呢,话说有没有想过为什么有三个选项呢?我放下一节来讲。

2. 安装失败-install from sources the package-下载源文件

我在非零报错那里讲到的一个问题,就是我们有一个选择:yes/no/cancel。一般也就是装或不装,为什么有三个呢?我考虑到了,但是还有点小问题,看下面吧:

Do you want to install from sources the package which needs compilation? (Yes/no/cancel)

看意思就是,我们是否要从包里下源文件,下源文件这一点就让我这个小白没懂了。根据我在网上看到大佬们的信息了,确认了这里选择yes是下载源文件,选择no是下载一个普通的二进制文件,选择cancel才是真的取消。

所以其实我们在这里选择no就能把包下好了,然后为了演示,我再删一次~

> install.packages('VIM') There is a binary version available but the source version is later: binary source needs_compilation VIM 6.1.0 6.1.1 TRUE Do you want to install from sources the package which needs compilation? (Yes/no/cancel) n trying URL 'https://cran.rstudio.com/bin/macosx/big-sur-arm64/contrib/4.1/VIM_6.1.0.tgz' Warning in install.packages : URL 'https://cran.rstudio.com/bin/macosx/big-sur-arm64/contrib/4.1/VIM_6.1.0.tgz': status was 'SSL connect error' Error in download.file(url, destfile, method, mode = "wb", ...) : cannot open URL 'https://cran.rstudio.com/bin/macosx/big-sur-arm64/contrib/4.1/VIM_6.1.0.tgz' Warning in install.packages : download of package ‘VIM’ failed

woc,发生甚么事了?没事,就是一个连接错误,~~开错门了,~~我们再来一次:

> install.packages('VIM') There is a binary version available but the source version is later: binary source needs_compilation VIM 6.1.0 6.1.1 TRUE Do you want to install from sources the package which needs compilation? (Yes/no/cancel) n trying URL 'https://cran.rstudio.com/bin/macosx/big-sur-arm64/contrib/4.1/VIM_6.1.0.tgz' Content type 'application/x-gzip' length 2655013 bytes (2.5 MB) ================================================== downloaded 2.5 MB The downloaded binary packages are in /var/folders/bj/w7w9z5vd3cz7vsrcfr7m0pz80000gn/T//Rtmph1ZFTh/downloaded_packages

立刻重来了一次,我们就成功了。

但是!我一开始也这样试过了,为啥我放弃了呢?因为我是用不了,而且我又没看懂报错。。。。Orz。。。:

> library(VIM) Loading required package: colorspace Loading required package: grid Error: package or namespace load failed for ‘VIM’ in loadNamespace(i, c(lib.loc, .libPaths()), versionCheck = vI[[i]]): there is no package called ‘vctrs’

wok,报错用不来哦,但其实这里没啥问题,看一下报错就知道了啊!就是没有’vctrs’包而已嘛,和下载源码文件的时候是一样的,没有就装啊:

> install.packages('vctrs') trying URL 'https://cran.rstudio.com/bin/macosx/big-sur-arm64/contrib/4.1/vctrs_0.3.8.tgz' Content type 'application/x-gzip' length 1450121 bytes (1.4 MB) ================================================== downloaded 1.4 MB The downloaded binary packages are in /var/folders/bj/w7w9z5vd3cz7vsrcfr7m0pz80000gn/T//Rtmph1ZFTh/downloaded_packages > library(VIM) VIM is ready to use. Suggestions and bug-reports can be submitted at: https://github.com/statistikat/VIM/issues Attaching package: ‘VIM’ The following object is masked from ‘package:datasets’: sleep

看,我们装好就能用了,所以这个报错就这样解决!

3. 关于我尚未解决的问题

其实和上面一样的报错,我这回是想下载链接数据库的包:‘RODBC’。

我一样先直接安装:

> install.packages('RODBC') Package which is only available in source form, and may need compilation of C/C++/Fortran: ‘RODBC’ Do you want to attempt to install these from sources? (Yes/no/cancel) Y installing the source package ‘RODBC’ trying URL 'https://cran.rstudio.com/src/contrib/RODBC_1.3-17.tar.gz' Content type 'application/x-gzip' length 1171335 bytes (1.1 MB) ================================================== downloaded 1.1 MB * installing *source* package ‘RODBC’ ... ** package ‘RODBC’ successfully unpacked and MD5 sums checked ** using staged installation checking for gcc... clang -arch arm64 checking whether the C compiler works... yes checking for C compiler default output file name... a.out checking for suffix of executables... checking whether we are cross compiling... no checking for suffix of object files... o checking whether we are using the GNU C compiler... yes checking whether clang -arch arm64 accepts -g... yes checking for clang -arch arm64 option to accept ISO C89... none needed checking how to run the C preprocessor... clang -arch arm64 -E checking for grep that handles long lines and -e... /usr/bin/grep checking for egrep... /usr/bin/grep -E checking for ANSI C header files... rm: conftest.dSYM: is a directory rm: conftest.dSYM: is a directory yes checking for sys/types.h... yes checking for sys/stat.h... yes checking for stdlib.h... yes checking for string.h... yes checking for memory.h... yes checking for strings.h... yes checking for inttypes.h... yes checking for stdint.h... yes checking for unistd.h... yes checking sql.h usability... no checking sql.h presence... no checking for sql.h... no checking sqlext.h usability... no checking sqlext.h presence... no checking for sqlext.h... no configure: error: "ODBC headers sql.h and sqlext.h not found" ERROR: configuration failed for package ‘RODBC’ * removing ‘/Library/Frameworks/R.framework/Versions/4.1-arm64/Resources/library/RODBC’ Warning in install.packages : installation of package ‘RODBC’ had non-zero exit status The downloaded source packages are in ‘/private/var/folders/bj/w7w9z5vd3cz7vsrcfr7m0pz80000gn/T/RtmpdQTPu2/downloaded_packages’

我们一样找老问题,不行我先试了一下下载二进制包,哦吼,没有二进制包。只能用yes解决了。。。

然后看这行:

configure: error: "ODBC headers sql.h and sqlext.h not found" ERROR: configuration failed for package ‘RODBC’

看懂了就是,我们没有sql.h 和 sqlext.h 这两个头文件。缺失看懂了,但是我根据网上的各种方法试过了,下载了unixodbc,安装了好几种东西,还是没用。我就放弃了…Orz

就到这了,如果遇到了问题再更~

希望大家都能解决好问题,然后我就可以参考了QAQ



【本文地址】

公司简介

联系我们

今日新闻

    推荐新闻

    专题文章
      CopyRight 2018-2019 实验室设备网 版权所有