#r #rstudio #homebrew
Вопрос:
У меня установлен R через homebrew, и я должен использовать пакет «мозаика».
Я уже установил «libpng» через homebrew.
which libpng-config
/opt/homebrew/bin/libpng-config
Однако, когда я пытаюсь установить mosaic, я получаю
clang -I"/opt/homebrew/Cellar/r/4.1.1/lib/R/include" -DNDEBUG -I/opt/homebrew/opt/gettext/include -I/opt/homebrew/opt/readline/include -I/opt/homebrew/opt/xz/include -I/opt/homebrew/include `libpng-config --cflags` -fPIC -Wno-implicit-function-declaration -c read.c -o read.o
* installing *source* package ‘png’ ...
** package ‘png’ successfully unpacked and MD5 sums checked
** using staged installation
** libs
/bin/sh: libpng-config: command not found
clang -I"/opt/homebrew/Cellar/r/4.1.1/lib/R/include" -DNDEBUG -I/opt/homebrew/opt/gettext/include -I/opt/homebrew/opt/readline/include -I/opt/homebrew/opt/xz/include -I/opt/homebrew/include `libpng-config --cflags` -fPIC -Wno-implicit-function-declaration -c write.c -o write.o
/bin/sh: libpng-config: command not found
clang -dynamiclib -Wl,-headerpad_max_install_names -undefined dynamic_lookup -single_module -multiply_defined suppress -L/opt/homebrew/Cellar/r/4.1.1/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 png.so read.o write.o -L/opt/homebrew/Cellar/r/4.1.1/lib/R/lib -lR -lintl -Wl,-framework -Wl,CoreFoundation
/bin/sh: libpng-config: command not found
/bin/sh: libpng-config: command not found
installing to /opt/homebrew/lib/R/4.1/site-library/00LOCK-png/00new/png/libs
** R
** inst
** byte-compile and prepare package for lazy loading
** help
*** installing help indices
** building package indices
** testing if installed package can be loaded from temporary location
Error: package or namespace load failed for ‘png’ in dyn.load(file, DLLpath = DLLpath, ...):
unable to load shared object '/opt/homebrew/lib/R/4.1/site-library/00LOCK-png/00new/png/libs/png.so':
dlopen(/opt/homebrew/lib/R/4.1/site-library/00LOCK-png/00new/png/libs/png.so, 6): Symbol not found: _png_create_info_struct
Referenced from: /opt/homebrew/lib/R/4.1/site-library/00LOCK-png/00new/png/libs/png.so
Expected in: flat namespace
in /opt/homebrew/lib/R/4.1/site-library/00LOCK-png/00new/png/libs/png.so
Error: loading failed
Execution halted
ERROR: loading failed
* removing ‘/opt/homebrew/lib/R/4.1/site-library/png’
ERROR: dependency ‘png’ is not available for package ‘latticeExtra’
* removing ‘/opt/homebrew/lib/R/4.1/site-library/latticeExtra’
ERROR: dependency ‘png’ is not available for package ‘leaflet’
* removing ‘/opt/homebrew/lib/R/4.1/site-library/leaflet’
ERROR: dependencies ‘latticeExtra’, ‘leaflet’ are not available for package ‘mosaic’
* removing ‘/opt/homebrew/lib/R/4.1/site-library/mosaic’
The downloaded source packages are in
‘/private/var/folders/1l/8fv6qzks1336kkvqwm2vghmr0000gn/T/Rtmpk8lbrp/downloaded_packages’
✔ Package 'mosaic' successfully installed.
Warning messages:
1: In utils::install.packages("latticeExtra", repos = "https://cran.rstudio.com/") :
installation of package ‘png’ had non-zero exit status
2: In utils::install.packages("latticeExtra", repos = "https://cran.rstudio.com/") :
installation of package ‘latticeExtra’ had non-zero exit status
3: In utils::install.packages("leaflet", repos = "https://cran.rstudio.com/") :
installation of package ‘png’ had non-zero exit status
4: In utils::install.packages("leaflet", repos = "https://cran.rstudio.com/") :
installation of package ‘leaflet’ had non-zero exit status
5: In utils::install.packages("mosaic", repos = "https://cran.rstudio.com/") :
installation of package ‘png’ had non-zero exit status
6: In utils::install.packages("mosaic", repos = "https://cran.rstudio.com/") :
installation of package ‘latticeExtra’ had non-zero exit status
7: In utils::install.packages("mosaic", repos = "https://cran.rstudio.com/") :
installation of package ‘leaflet’ had non-zero exit status
8: In utils::install.packages("mosaic", repos = "https://cran.rstudio.com/") :
installation of package ‘mosaic’ had non-zero exit status
Я не уверен, как поступить дальше. Нужно ли мне изменять файл Makevars, и если да, то что?
Ответ №1:
Я не мог понять, как установить «мозаику» через RStudio.
Что я сделал, чтобы решить эту проблему, так это запустил экземпляр R в терминале, который libpng-config
работал, и запустил install.package('mosaic')
его там.
Это удалось, и когда я открыл RStudio, «мозаика» была установлена и работала.
Ответ №2:
У меня была аналогичная ошибка при попытке установить пакет png из RStudio в Mac M1, установка пакета из сеанса терминала r решила проблему.