我是Linux和R的新手。
我在Ubuntu 11.04中安装了R 2.12。今天我试图安装一个新的包,所以我运行以下命令:
install.packages('XML')
但安装失败,并提供以下信息:
* installing *source* package ‘XML’ ... checking for gcc... gcc checking for C compiler default output file name... a.out checking whether the C compiler works... yes checking whether we are cross compiling... no checking for suffix of executables... checking for suffix of object files... o checking whether we are using the GNU C compiler... yes checking whether gcc accepts -g... yes checking for gcc option to accept ISO C89... none needed checking how to run the C preprocessor... gcc -E No ability to remove finalizers on externalptr objects in this verison of R checking for sed... /bin/sed checking for pkg-config... /usr/bin/pkg-config checking for xml2-config... no Cannot find xml2-config ERROR: configuration Failed for package ‘XML’ * removing ‘/home/spirit/R/i686-pc-linux-gnu-library/2.12/XML’ The downloaded packages are in ‘/tmp/RtmpoZYxnv/downloaded_packages’ Warning message: In install.packages("XML") : installation of package 'XML' had non-zero exit status
我也试过:
sudo install.packages('XML')
但它给出相同的错误信息。
任何人都可以给我任何建议吗?提前致谢。
install.packages方法
你需要安装ubuntu包libxml2-dev所以在shell提示符下输入:
sudo apt-get update sudo apt-get install libxml2-dev
你需要特别的sudo权力。
Ubuntu包方法
正如Richie和Dirk所说,你也可以使用:
sudo apt-get install r-cran-xml
如果你沿着这个路径,我建议你检查出R ubuntu sources页,这将确保您有一个当前版本的R和相关的R包。这可能是重要的,如果你使用的ubuntu的LTS版本。