MacOS上R中的软件包安装失败
我尝试在R Studio中安装两个软件包:tidyverse和quantmod。然而,两者都给了我错误,我不明白为什么(谷歌搜索无助于理解这个问题) 对于整洁的诗句,我得到:MacOS上R中的软件包安装失败,r,tidyverse,quantmod,R,Tidyverse,Quantmod,我尝试在R Studio中安装两个软件包:tidyverse和quantmod。然而,两者都给了我错误,我不明白为什么(谷歌搜索无助于理解这个问题) 对于整洁的诗句,我得到: > install.packages("tidyverse") also installing the dependency ‘xml2’ There are binary versions available but the source versions are later: bina
> install.packages("tidyverse")
also installing the dependency ‘xml2’
There are binary versions available but the source versions are later:
binary source needs_compilation
xml2 1.1.1 1.2.0 TRUE
tidyverse 1.1.1 1.2.1 FALSE
Do you want to install from sources the package which needs compilation?
y/n: y
installing the source packages ‘xml2’, ‘tidyverse’
trying URL 'https://cran.rstudio.com/src/contrib/xml2_1.2.0.tar.gz'
Content type 'application/x-gzip' length 251614 bytes (245 KB)
==================================================
downloaded 245 KB
trying URL 'https://cran.rstudio.com/src/contrib/tidyverse_1.2.1.tar.gz'
Content type 'application/x-gzip' length 61647 bytes (60 KB)
==================================================
downloaded 60 KB
* installing *source* package ‘xml2’ ...
** package ‘xml2’ successfully unpacked and MD5 sums checked
Found pkg-config cflags and libs!
Using PKG_CFLAGS=-I/usr/include/libxml2
Using PKG_LIBS=-L/usr/lib -lxml2 -lz -lpthread -licucore -lm
------------------------- ANTICONF ERROR ---------------------------
Configuration failed because libxml-2.0 was not found. Try installing:
* deb: libxml2-dev (Debian, Ubuntu, etc)
* rpm: libxml2-devel (Fedora, CentOS, RHEL)
* csw: libxml2_dev (Solaris)
If libxml-2.0 is already installed, check that 'pkg-config' is in your
PATH and PKG_CONFIG_PATH contains a libxml-2.0.pc file. If pkg-config
is unavailable you can set INCLUDE_DIR and LIB_DIR manually via:
R CMD INSTALL --configure-vars='INCLUDE_DIR=... LIB_DIR=...'
--------------------------------------------------------------------
ERROR: configuration failed for package ‘xml2’
* removing ‘/Library/Frameworks/R.framework/Versions/3.3/Resources/library/xml2’
Warning in install.packages :
installation of package ‘xml2’ had non-zero exit status
ERROR: dependency ‘xml2’ is not available for package ‘tidyverse’
* removing ‘/Library/Frameworks/R.framework/Versions/3.3/Resources/library/tidyverse’
Warning in install.packages :
installation of package ‘tidyverse’ had non-zero exit status
The downloaded source packages are in
‘/private/var/folders/rs/dj94tlfj263dzp30z6kvqb5m0000gn/T/RtmpH2BAQU/downloaded_packages’
对于quantmod,我还得到两个错误:
make: gfortran-4.8: No such file or directory
make: *** [period.max.o] Error 1
ERROR: compilation failed for package ‘xts’
* removing ‘/Library/Frameworks/R.framework/Versions/3.3/Resources/library/xts’
* restoring previous ‘/Library/Frameworks/R.framework/Versions/3.3/Resources/library/xts’
make: gfortran-4.8: No such file or directory
make: *** [movingAverages.o] Error 1
ERROR: compilation failed for package ‘TTR’
* removing ‘/Library/Frameworks/R.framework/Versions/3.3/Resources/library/TTR’
Warning in install.packages :
installation of package ‘TTR’ had non-zero exit status
ERROR: dependency ‘TTR’ is not available for package ‘quantmod’
* removing ‘/Library/Frameworks/R.framework/Versions/3.3/Resources/library/quantmod’
我想这可能与我的道路有关,但我没有足够的经验让它发挥作用 通过卸载通过自制安装的所有R版本,我解决了这一问题:
brew uninstall --force r
然后从CRAN重新安装。我遇到了同样的问题。 我最终通过引用解决了这个问题 首先,在的指示下手动安装lxml2,但在安装时出错:
。。。
mkdir:/usr/include:不允许操作
...
然后将前缀更改为:
/configure--prefix=/usr/local--disable static--with history&&make
sudo制作安装
然后再次安装R软件包“xml2”并确定。您是否尝试过:
brew安装libxml2
?(假设您使用的是自制)它对tidyverse有效!实际上,出于某种原因,我首先必须运行“xcode select--install”,然后使用您建议的命令。非常感谢。然而,对于您需要的gfortran包QuantMod来说,这似乎是一个不同的问题:您还需要libcurl。你应该考虑从CLAN安装二进制文件,而不是使用自制程序,它安装了一个过时的版本。我刚刚安装了GoFrTRAN 6.1,但它似乎解决不了这个问题,而且我也有同样的错误。我不明白这里发生了什么我要试试,我使用的是R studio,我应该卸载Rstudio吗?不,Rstudio只是一个IDE(集成开发环境),但不是R本身。R需要单独安装在您的系统上,在MacOS上,建议使用CRAN安装,因为自制的安装可能会使事情发生意外。如果您仍然存在gfortran问题,则可能值得查看另一个问题(&A)答案这里是我的:只需删除一个RStudio配置文件就可以解决这个问题。您建议的命令解决了我在quantmod和tidyverse上遇到的两个问题!非常感谢。