Conda环境下无法安装R包terra的问题求助
在MacOS Conda环境中安装R包terra失败求助
我正在MacOS笔记本上配置名为r_env的Conda环境,尝试安装R包terra时持续报错,求助解决方法。
直接安装terra的错误信息
执行install.packages('terra')后出现以下错误:
> install.packages('terra') Installing package into ‘/Users/ft/Library/R/arm64/4.3/library’ (as ‘lib’ is unspecified) trying URL 'https://ftp.osuosl.org/pub/cran/src/contrib/terra_1.7-71.tar.gz' Content type 'application/x-gzip' length 836573 bytes (816 KB) ================================================== downloaded 816 KB * installing *source* package ‘terra’ ... ** package ‘terra’ successfully unpacked and MD5 sums checked ** using staged installation configure: CC: arm64-apple-darwin20.0.0-clang configure: CXX: arm64-apple-darwin20.0.0-clang++ -std=gnu++17 checking for gdal-config... /opt/anaconda3/envs/r_env/bin/gdal-config checking gdal-config usability... yes configure: GDAL: 3.8.4 checking GDAL version >= 2.0.1... yes checking for arm64-apple-darwin20.0.0-gcc... arm64-apple-darwin20.0.0-clang 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 the compiler supports GNU C... yes checking whether arm64-apple-darwin20.0.0-clang accepts -g... yes checking for arm64-apple-darwin20.0.0-clang option to enable C11 features... none needed checking for stdio.h... yes checking for stdlib.h... yes checking for string.h... yes checking for inttypes.h... yes checking for stdint.h... yes checking for strings.h... yes checking for sys/stat.h... yes checking for sys/types.h... yes checking for unistd.h... yes checking for gdal.h... yes checking GDAL: linking with --libs only... yes checking GDAL: /opt/anaconda3/envs/r_env/share/gdal/pcs.csv readable... no checking GDAL: checking whether PROJ is available for linking:... yes checking GDAL: checking whether PROJ is available for running:... dyld[4535]: Library not loaded: @rpath/libgdal.34.dylib Referenced from: <77AD9583-9BF2-33BE-B6AF-B9DE29216B97> /private/var/folders/mg/dbb5s6cn0515h5msqv6clwpr0000gp/T/RtmpPr9ZBY/R.INSTALL107934ca07d1/terra/gdal_proj Reason: tried: '/usr/local/lib/libgdal.34.dylib' (no such file), '/usr/lib/libgdal.34.dylib' (no such file, not in dyld cache) ./configure: line 3682: 4535 Abort trap: 6 ./gdal_proj no configure: error: OGRCoordinateTransformation() does not return a coord.trans: PROJ not available? ERROR: configuration failed for package ‘terra’
当前环境信息
R环境详情
> sessionInfo() R version 4.3.3 (2024-02-29) Platform: aarch64-apple-darwin20.0.0 (64-bit) Running under: macOS Ventura 13.6.6 Matrix products: default BLAS: /opt/anaconda3/envs/r_env/lib/libblas.3.9.0.dylib LAPACK: /opt/anaconda3/envs/r_env/lib/liblapack.3.9.0.dylib locale: [1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8 time zone: America/New_York tzcode source: internal attached base packages: [1] stats graphics grDevices utils datasets methods base loaded via a namespace (and not attached): [1] compiler_4.3.3 tools_4.3.3
Conda环境已安装的相关依赖
conda list | grep gdal gdal 3.8.4 py312h56161e1_0 conda-forge libgdal 3.8.4 ha86f356_0 conda-forge conda list | grep proj proj 9.3.1 h93d94ba_0 conda-forge r-rprojroot 2.0.4 r43hc72bb7e_0 conda-forge
已尝试的解决方法及结果
- 指定环境内库路径安装:执行以下命令后仍出现相同错误
install.packages('terra',configure.args="--with-gdal-lib=/opt/anaconda3/envs/r_env/lib/ --with-proj-lib=/opt/anaconda3/envs/r_env/lib/") - 尝试共享库安装:安装进度推进后,在加载阶段报错
... ** testing if installed package can be loaded from temporary location Error: package or namespace load failed for ‘terra’ in dyn.load(file, DLLpath = DLLpath, ...): unable to load shared object '/Users/ft/Library/R/arm64/4.3/library/00LOCK-terra/00new/terra/libs/terra.dylib': dlopen(/Users/ft/Library/R/arm64/4.3/library/00LOCK-terra/00new/terra/libs/terra.dylib, 0x0006): symbol not found in flat namespace '__Z6Rlog1pd' Error: loading failed Execution halted ERROR: loading failed * removing ‘/Users/ft/Library/R/arm64/4.3/library/terra’ - 尝试通过Conda安装r-terra:在conda-forge和defaults频道中找不到该包
conda install terra Channels: - conda-forge - defaults Platform: osx-arm64 Collecting package metadata (repodata.json): done Solving environment: failed PackagesNotFoundError: The following packages are not available from current channels: - terra Current channels: - https://conda.anaconda.org/conda-forge - defaults
内容的提问来源于stack exchange,提问作者Florian U.H. Tornow
相关产品推荐
相关产品推荐

