在 R (Big Sur) 中安装包 "sf" 时遇到问题
Trouble installing package "sf" in R (Big Sur)
我尝试安装 sf
包,因为它是 tidycensus
的依赖项,而 tidycensus
正是我想要使用的包。
我正在使用 Big Sur 的 Mac。根据 r-spatial 的 Github,我尝试按照安装说明 here 进行操作,但没有成功。我的 sessionInfo()
:
R version 4.1.0 (2021-05-18)
Platform: aarch64-apple-darwin20.4.0 (64-bit)
Running under: macOS Big Sur 11.6
Matrix products: default
BLAS: /opt/homebrew/Cellar/openblas/0.3.20/lib/libopenblasp-r0.3.20.dylib
LAPACK: /opt/homebrew/Cellar/r/4.1.0/lib/R/lib/libRlapack.dylib
locale:
[1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8
attached base packages:
[1] stats graphics grDevices utils datasets methods base
loaded via a namespace (and not attached):
[1] compiler_4.1.0
我试过了
library(devtools)
install_github("r-spatial/sf",configure.args="--with-proj-lib=/opt/homebrew/opt/proj/lib")
错误:
Installing package into ‘/opt/homebrew/lib/R/4.1/site-library’
(as ‘lib’ is unspecified)
* installing *source* package ‘sf’ ...
** using staged installation
configure: CC: /opt/homebrew/opt/llvm/bin/clang
configure: CXX: /opt/homebrew/opt/llvm/bin/clang++ -std=gnu++11
checking for gdal-config... /opt/homebrew/Caskroom/miniforge/base/bin/gdal-config
checking gdal-config usability... yes
configure: GDAL: 3.4.1
checking GDAL version >= 2.0.1... yes
checking for gcc... /opt/homebrew/opt/llvm/bin/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 we are using the GNU C compiler... yes
checking whether /opt/homebrew/opt/llvm/bin/clang accepts -g... yes
checking for /opt/homebrew/opt/llvm/bin/clang option to accept ISO C89... none needed
checking how to run the C preprocessor... /opt/homebrew/opt/llvm/bin/clang -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 gdal.h usability... yes
checking gdal.h presence... yes
checking for gdal.h... yes
checking GDAL: linking with --libs only... yes
checking GDAL: /opt/homebrew/Caskroom/miniforge/base/share/gdal/pcs.csv readable... no
checking GDAL: checking whether PROJ is available for linking:... yes
checking GDAL: checking whether PROJ is available fur running:... dyld: Library not loaded: @rpath/libgdal.30.dylib
Referenced from: /private/var/folders/4b/2jtbyjzd1w5gsdm_g_jcpr2h0000gn/T/Rtmp2cQwgC/R.INSTALL5d284632664c/sf/./gdal_proj
Reason: image not found
./configure: line 3625: 24751 Abort trap: 6 ./gdal_proj
no
configure: error: OGRCoordinateTransformation() does not return a coord.trans: PROJ not available?
ERROR: configuration failed for package ‘sf’
* removing ‘/opt/homebrew/lib/R/4.1/site-library/sf’
现在,可能会把我搞砸(但我不知道如何解决)的是 gdal-config 既在 /opt/homebrew/Caskroom/miniforge/base/bin/
中,也在 /opt/homebrew/opt/gdal/bin/
中
gdal
、proj
和 geos
都住在 /opt/homebrew/opt/
感谢@IRTFM,解决方案是从 CRAN 下载二进制文件,然后使用 R CMD INSTALL
。然后我可以通过 install.packages()
安装 tigris
和 tidycensus
我尝试安装 sf
包,因为它是 tidycensus
的依赖项,而 tidycensus
正是我想要使用的包。
我正在使用 Big Sur 的 Mac。根据 r-spatial 的 Github,我尝试按照安装说明 here 进行操作,但没有成功。我的 sessionInfo()
:
R version 4.1.0 (2021-05-18)
Platform: aarch64-apple-darwin20.4.0 (64-bit)
Running under: macOS Big Sur 11.6
Matrix products: default
BLAS: /opt/homebrew/Cellar/openblas/0.3.20/lib/libopenblasp-r0.3.20.dylib
LAPACK: /opt/homebrew/Cellar/r/4.1.0/lib/R/lib/libRlapack.dylib
locale:
[1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8
attached base packages:
[1] stats graphics grDevices utils datasets methods base
loaded via a namespace (and not attached):
[1] compiler_4.1.0
我试过了
library(devtools)
install_github("r-spatial/sf",configure.args="--with-proj-lib=/opt/homebrew/opt/proj/lib")
错误:
Installing package into ‘/opt/homebrew/lib/R/4.1/site-library’
(as ‘lib’ is unspecified)
* installing *source* package ‘sf’ ...
** using staged installation
configure: CC: /opt/homebrew/opt/llvm/bin/clang
configure: CXX: /opt/homebrew/opt/llvm/bin/clang++ -std=gnu++11
checking for gdal-config... /opt/homebrew/Caskroom/miniforge/base/bin/gdal-config
checking gdal-config usability... yes
configure: GDAL: 3.4.1
checking GDAL version >= 2.0.1... yes
checking for gcc... /opt/homebrew/opt/llvm/bin/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 we are using the GNU C compiler... yes
checking whether /opt/homebrew/opt/llvm/bin/clang accepts -g... yes
checking for /opt/homebrew/opt/llvm/bin/clang option to accept ISO C89... none needed
checking how to run the C preprocessor... /opt/homebrew/opt/llvm/bin/clang -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 gdal.h usability... yes
checking gdal.h presence... yes
checking for gdal.h... yes
checking GDAL: linking with --libs only... yes
checking GDAL: /opt/homebrew/Caskroom/miniforge/base/share/gdal/pcs.csv readable... no
checking GDAL: checking whether PROJ is available for linking:... yes
checking GDAL: checking whether PROJ is available fur running:... dyld: Library not loaded: @rpath/libgdal.30.dylib
Referenced from: /private/var/folders/4b/2jtbyjzd1w5gsdm_g_jcpr2h0000gn/T/Rtmp2cQwgC/R.INSTALL5d284632664c/sf/./gdal_proj
Reason: image not found
./configure: line 3625: 24751 Abort trap: 6 ./gdal_proj
no
configure: error: OGRCoordinateTransformation() does not return a coord.trans: PROJ not available?
ERROR: configuration failed for package ‘sf’
* removing ‘/opt/homebrew/lib/R/4.1/site-library/sf’
现在,可能会把我搞砸(但我不知道如何解决)的是 gdal-config 既在 /opt/homebrew/Caskroom/miniforge/base/bin/
中,也在 /opt/homebrew/opt/gdal/bin/
中
gdal
、proj
和 geos
都住在 /opt/homebrew/opt/
感谢@IRTFM,解决方案是从 CRAN 下载二进制文件,然后使用 R CMD INSTALL
。然后我可以通过 install.packages()
tigris
和 tidycensus