$ brew install libpq检查库是否指向自身:$ otool -l/usr/local/Cellar/libpq/13.0/lib/libpq.5.dylib |fgrep -A2 LC_ID_DYLIB如果不是,则将其指向自己:$ sudo install_name_tool -id/usr/local/Cellar/libpq/13.0/lib/libpq.5.dylib/usr/local/Cellar/libpq/13.0/lib/libpq.5.dylib并将 libpq 的新路径链接到引用它的每个 R 包二进制文件:$ sudo install_name_tool -change/usr/lib/libpq.5.dylib [new_path] [path_to_binary]在这种情况下,对于 sf 和 rgdal:$ sudo install_name_tool -change/usr/lib/libpq.5.dylib/usr/local/Cellar/libpq/13.1/lib/libpq.5.dylib/Library/Frameworks/R.framework/Versions/4.0/Resources/library/sf/libs/sf.so$ sudo install_name_tool -change/usr/lib/libpq.5.dylib/usr/local/Cellar/libpq/13.1/lib/libpq.5.dylib/Library/Frameworks/R.framework/Versions/4.0/Resources/library/rgdal/libs/rgdal.soI installed the packages tidycensus and mapview in RStudio but I get the following error when I try load either one:library(tidycensus)library(mapview)I've tried this solution but it is not solving my problem. 解决方案 This issue indeed happened to me today when upgraded to Big Sur. After researching, finally I found a solution here:copy libpq.5.dylib to /usr/lib/libpq.5.dylibLooks like macOS is keeping libraries on /usr/lib closed. Basically is needed to point back /usr/lib/libpq.5.dylib against another libpq, like the one you get by installing it with Homebrew.This is what worked for me, first uninstall sf and rgdal packages in R and use HomeBrew to install libpq if needed:$ brew install libpqCheck if library is pointing itself:$ otool -l /usr/local/Cellar/libpq/13.0/lib/libpq.5.dylib | fgrep -A2 LC_ID_DYLIBIf not, point it against itself:$ sudo install_name_tool -id /usr/local/Cellar/libpq/13.0/lib/libpq.5.dylib /usr/local/Cellar/libpq/13.0/lib/libpq.5.dylibAnd link the new path of libpq to each R package binary that references to it:$ sudo install_name_tool -change /usr/lib/libpq.5.dylib [new_path] [path_to_binary]In this case, for sf and rgdal:$ sudo install_name_tool -change /usr/lib/libpq.5.dylib /usr/local/Cellar/libpq/13.1/lib/libpq.5.dylib /Library/Frameworks/R.framework/Versions/4.0/Resources/library/sf/libs/sf.so$ sudo install_name_tool -change /usr/lib/libpq.5.dylib /usr/local/Cellar/libpq/13.1/lib/libpq.5.dylib /Library/Frameworks/R.framework/Versions/4.0/Resources/library/rgdal/libs/rgdal.so 这篇关于无法在 Macbook 上加载 tidycensus 和地图视图包的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 09-27 09:52