r - 无法在 R 中安装软件包
问题描述
我刚开始使用 R。我在 M1 BigSur Mac 上。
我已经尝试了几个软件包,但我无法安装其中的任何一个。
例如,swirl
> install.packages("swirl")
trying URL 'https://cran.rstudio.com/src/contrib/swirl_2.4.5.tar.gz'
Content type 'application/x-gzip' length 108847 bytes (106 KB)
==================================================
downloaded 106 KB
* installing *source* package ‘swirl’ ...
** package ‘swirl’ successfully unpacked and MD5 sums checked
** using staged installation
** R
** inst
** byte-compile and prepare package for lazy loading
Error in dyn.load(file, DLLpath = DLLpath, ...) :
unable to load shared object '/opt/homebrew/Cellar/r/4.1.0/lib/R/library/stringi/libs/stringi.so':
dlopen(/opt/homebrew/Cellar/r/4.1.0/lib/R/library/stringi/libs/stringi.so, 6): no suitable image found. Did find:
/opt/homebrew/Cellar/r/4.1.0/lib/R/library/stringi/libs/stringi.so: mach-o, but wrong architecture
/opt/homebrew/Cellar/r/4.1.0/lib/R/library/stringi/libs/stringi.so: mach-o, but wrong architecture
Calls: <Anonymous> ... namespaceImport -> loadNamespace -> library.dynam -> dyn.load
Execution halted
ERROR: lazy loading failed for package ‘swirl’
* removing ‘/opt/homebrew/Cellar/r/4.1.0/lib/R/library/swirl’
Warning in install.packages :
installation of package ‘swirl’ had non-zero exit status
The downloaded source packages are in
‘/private/var/folders/t6/qy2rcbdx0g9_fv98q1g48v_h0000gn/T/RtmpDAcI28/downloaded_packages’
Updating HTML index of packages in '.Library'
Making 'packages.html' ... done
tidyverse
它一直在重复以下输出,但没有完成正确的安装。
* installing *source* package ‘cpp11’ ...
** package ‘cpp11’ successfully unpacked and MD5 sums checked
** using staged installation
** R
** inst
** byte-compile and prepare package for lazy loading
** help
*** installing help indices
** building package indices
** installing vignettes
** testing if installed package can be loaded from temporary location
** testing if installed package can be loaded from final location
** testing if installed package keeps a record of temporary installation path
* DONE (cpp11)
* installing *source* package ‘Rcpp’ ...
** package ‘Rcpp’ successfully unpacked and MD5 sums checked
** using staged installation
** libs
clang++ -std=gnu++14 -I"/opt/homebrew/Cellar/r/4.1.0/lib/R/include" -DNDEBUG -I../inst/include/ -I/opt/homebrew/opt/gettext/include -I/opt/homebrew/opt/readline/include -I/opt/homebrew/opt/xz/include -I/opt/homebrew/include -fPIC -g -O2 -c api.cpp -o api.o
clang++ -std=gnu++14 -I"/opt/homebrew/Cellar/r/4.1.0/lib/R/include" -DNDEBUG -I../inst/include/ -I/opt/homebrew/opt/gettext/include -I/opt/homebrew/opt/readline/include -I/opt/homebrew/opt/xz/include -I/opt/homebrew/include -fPIC -g -O2 -c attributes.cpp -o attributes.o
clang++ -std=gnu++14 -I"/opt/homebrew/Cellar/r/4.1.0/lib/R/include" -DNDEBUG -I../inst/include/ -I/opt/homebrew/opt/gettext/include -I/opt/homebrew/opt/readline/include -I/opt/homebrew/opt/xz/include -I/opt/homebrew/include -fPIC -g -O2 -c barrier.cpp -o barrier.o
clang++ -std=gnu++14 -I"/opt/homebrew/Cellar/r/4.1.0/lib/R/include" -DNDEBUG -I../inst/include/ -I/opt/homebrew/opt/gettext/include -I/opt/homebrew/opt/readline/include -I/opt/homebrew/opt/xz/include -I/opt/homebrew/include -fPIC -g -O2 -c date.cpp -o date.o
clang++ -std=gnu++14 -I"/opt/homebrew/Cellar/r/4.1.0/lib/R/include" -DNDEBUG -I../inst/include/ -I/opt/homebrew/opt/gettext/include -I/opt/homebrew/opt/readline/include -I/opt/homebrew/opt/xz/include -I/opt/homebrew/include -fPIC -g -O2 -c module.cpp -o module.o
clang++ -std=gnu++14 -I"/opt/homebrew/Cellar/r/4.1.0/lib/R/include" -DNDEBUG -I../inst/include/ -I/opt/homebrew/opt/gettext/include -I/opt/homebrew/opt/readline/include -I/opt/homebrew/opt/xz/include -I/opt/homebrew/include -fPIC -g -O2 -c rcpp_init.cpp -o rcpp_init.o
clang++ -std=gnu++14 -dynamiclib -Wl,-headerpad_max_install_names -undefined dynamic_lookup -single_module -multiply_defined suppress -L/opt/homebrew/Cellar/r/4.1.0/lib/R/lib -L/opt/homebrew/opt/gettext/lib -L/opt/homebrew/opt/readline/lib -L/opt/homebrew/opt/xz/lib -L/opt/homebrew/lib -o Rcpp.so api.o attributes.o barrier.o date.o module.o rcpp_init.o -L/opt/homebrew/Cellar/r/4.1.0/lib/R/lib -lR -lintl -Wl,-framework -Wl,CoreFoundation
我试过了install.package('swirl', type='mac.binary')
。
它强制安装成功,但是当我调用时它会给出以下错误library("swirl")
:
Error: package or namespace load failed for ‘swirl’ in dyn.load(file, DLLpath = DLLpath, ...):
unable to load shared object '/opt/homebrew/Cellar/r/4.1.0/lib/R/library/stringi/libs/stringi.so':
dlopen(/opt/homebrew/Cellar/r/4.1.0/lib/R/library/stringi/libs/stringi.so, 6): no suitable image found. Did find:
/opt/homebrew/Cellar/r/4.1.0/lib/R/library/stringi/libs/stringi.so: mach-o, but wrong architecture
/opt/homebrew/Cellar/r/4.1.0/lib/R/library/stringi/libs/stringi.so: mach-o, but wrong architecture
解决方案
推荐阅读
- angular - 在不同组件中使用相同的对象数组,如果对一个对象进行任何更新,将在角度 8 中显示其他组件中的更新
- php - Why does this bash script work if called from the command line but not when called from a php script run by a webpage?
- java - Adding Dynamically created queues to a listener RabbitMq Spring
- macos - "zsh: command not found: expo" on macOS
- hive - Airflow: how can i automate such that a query runs for every date specified rather than hard coding?
- go - reflect.TypeOf((*error)(nil)).Elem()` 是什么意思?
- python - How to ask user whether to exit or keep running?
- python - For folder in dir, enter it and delete files if condition is met
- java - Text to Speech Android Studio
- javascript - 有没有办法改变部分输入值的 CSS 样式?