conda 安装r-units(ERROR: configuration failed for package ‘units’)
一开始,我是想安装ggVennDiagram
这个包的,但是因为units
和sf
这两个包安装失败,导致ggVennDiagram
不能安装成功。
注:我是使用conda虚拟环境中的R
然后我就单独安装了units
这个包,提示
configure: error: in `/tmp/RtmpxsCHZa/R.INSTALL18ae05e2eac89/units':
configure: error:
--------------------------------------------------------------------------------
Configuration failed because libudunits2.so was not found. Try installing:
* deb: libudunits2-dev (Debian, Ubuntu, ...)
* rpm: udunits2-devel (Fedora, EPEL, ...)
* brew: udunits (OSX)
If udunits2 is already installed in a non-standard location, use:
--configure-args='--with-udunits2-lib=/usr/local/lib'
if the library was not found, and/or:
--configure-args='--with-udunits2-include=/usr/include/udunits2'
if the header was not found, replacing paths with appropriate values.
You can alternatively set UDUNITS2_INCLUDE and UDUNITS2_LIBS manually.
--------------------------------------------------------------------------------
See `config.log' for more details
ERROR: configuration failed for package ‘units’
* removing ‘/home/user/software/anaconda/envs/R/lib/R/library/units’
根据提示,我通过命令安装
yum install udunits2-devel
同时安装命令换成
install.packages("units",
configure.args = c("--with-udunits2-include=/usr/include/udunits2 --with-udunits2-lib=/usr/lib64"))
注:这里用/usr/lib64而不是提示用的/usr/local/lib,是因为libudunits2.so是在/usr/lib64里。
但是并未安装成功,还是有上面的错误输出。
由于我是在conda 的虚拟环境中使用,那么把所需要的依赖软件也在虚拟环境中安装下吧,
### linux shell
$ conda activate ENV_NAME
$ conda install -c conda-forge udunits2
在R里
> config <- c(units="--with-udunits2-lib=/path/to/home/directory/anaconda/envs/ENV/lib --with-udunits2-include=/path/to/home/directory/anaconda/envs/ENV/include")
> install.packages("units", configure.args = config )
注: /path/to/home/directory/anaconda/envs/ENV/lib 和 /path/to/home/directory/anaconda/envs/ENV/include 是虚拟环境ENV地址下的两个目录。虚拟环境地址可以通过conda env list知道
然后呢units
安装成功。用conda把 sf
也安装了
conda install -c conda-forge r-sf
最后再安装一下ggVennDiagram
成功
install.packages("ggVennDiagram")
参考
Troubles installing units (Ubuntu 18.04.1) · Issue #223 · r-quantities/units (github.com)