微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

在MAC上加载软件包

如何解决在MAC上加载软件包

在我的PC上训练neuralnetwork()到现在为止已经拖了24多个小时,但这是另一个问题。在运行的同时,我(今天)在我的MAC上下载了R studio以同时运行其他代码。但是,我无法设置它。我在PC上使用的相同软件包不会在此MAC上加载。以下是这种情况:

library(mice)
library(dlookr)
library(rgl)

让我们放大dlookr

> library(dlookr)
Loading required package: mice
Error: package or namespace load Failed for ‘mice’ in loadNamespace(j <- i[[1L]],c(lib.loc,.libPaths()),versionCheck = vI[[j]]):
 there is no package called ‘broom’
Error: package ‘mice’ Could not be loaded

如果我能解决mice,我将得到2比1的收益。就是这样:

    > library(mice)
Error: package or namespace load Failed for ‘mice’ in loadNamespace(j <- i[[1L]],versionCheck = vI[[j]]):
 there is no package called ‘broom’

在我的PC上,该功能在没有broom的情况下仍然有效,但是无论如何,我都会一起玩。

> install.packages("broom")

  There is a binary version available but the source version
  is later:
      binary source needs_compilation
broom  0.5.5  0.7.0             FALSE

installing the source package ‘broom’

trying URL 'https://cran.rstudio.com/src/contrib/broom_0.7.0.tar.gz'
Content type 'application/x-gzip' length 604195 bytes (590 KB)
==================================================
downloaded 590 KB

* installing *source* package ‘broom’ ...
** package ‘broom’ successfully unpacked and MD5 sums checked
** R
** inst
** byte-compile and prepare package for lazy loading
Error : object ‘pivot_longer’ is not exported by 'namespace:tidyr'
ERROR: lazy loading Failed for package ‘broom’
* removing ‘/Library/Frameworks/R.framework/Versions/3.5/Resources/library/broom’
Warning in install.packages :
  installation of package ‘broom’ had non-zero exit status

The downloaded source packages are in
    ‘/private/var/folders/yl/tb3dwr4x5gd79c_lbr_krp9h0000gn/T/RtmpK9gAxy/downloaded_packages’

然后...

> library(broom)
Error in library(broom) : there is no package called ‘broom’

如果我可以安装和加载broom,是否可以加载micedlookr?而且更重要的是,为什么我不能安装和加载broom

我已经注意到,在安装和加载我使用的其他一些软件包时,其中一些类似于broom的软件包具有二进制版本和源版本。但是,与broom不同的是,他们给了我一个我要安装的选项。在这些情况下,如果我选择安装源版本,则这些软件包也不会加载。我必须回去安装这些软件包的替代版本,而这在我的PC上再也不需要担心。我不知道这两个版本之间的技术区别是什么,但是认情况下,broom本身是否安装了无效版本?如果可以,我该如何选择并安装其他版本?

rgl似乎是另一个具有源代码和二进制版本的库。 rgl使我可以选择安装哪个选项;但是,两者都不起作用。这是R安装并无法加载二进制版本:

> install.packages("rgl")

  There is a binary version available but the source version
  is later:
      binary   source needs_compilation
rgl 0.100.50 0.100.54              TRUE

Do you want to install from sources the package which needs compilation? (Yes/no/cancel) no
trying URL 'https://cran.rstudio.com/bin/macosx/el-capitan/contrib/3.5/rgl_0.100.50.tgz'
Content type 'application/x-gzip' length 4709273 bytes (4.5 MB)
==================================================
downloaded 4.5 MB


The downloaded binary packages are in
    /var/folders/yl/tb3dwr4x5gd79c_lbr_krp9h0000gn/T//RtmpK9gAxy/downloaded_packages
> library(rgl)
Error in dyn.load(file,DLLpath = DLLpath,...) : 
  unable to load shared object '/Library/Frameworks/R.framework/Versions/3.5/Resources/library/rgl/libs/rgl.so':
  dlopen(/Library/Frameworks/R.framework/Versions/3.5/Resources/library/rgl/libs/rgl.so,6): Library not loaded: /opt/X11/lib/libglu.1.dylib
  Referenced from: /Library/Frameworks/R.framework/Versions/3.5/Resources/library/rgl/libs/rgl.so
  Reason: image not found
Error: package or namespace load Failed for ‘rgl’:
 .onLoad Failed in loadNamespace() for 'rgl',details:
  call: NULL
  error:    Loading rgl's DLL Failed. 
    On MacOS,rgl depends on XQuartz,which you can download from xquartz.org.

在这里它正在安装并且无法加载源版本:

> install.packages("rgl")

  There is a binary version available but the source version
  is later:
      binary   source needs_compilation
rgl 0.100.50 0.100.54              TRUE

Do you want to install from sources the package which needs compilation? (Yes/no/cancel) yes
installing the source package ‘rgl’

trying URL 'https://cran.rstudio.com/src/contrib/rgl_0.100.54.tar.gz'
Content type 'application/x-gzip' length 2952743 bytes (2.8 MB)
==================================================
downloaded 2.8 MB

* installing *source* package ‘rgl’ ...
** package ‘rgl’ successfully unpacked and MD5 sums checked
checking for gcc... 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 clang accepts -g... yes
checking for clang option to accept ISO C89... none needed
checking how to run the C preprocessor... clang -E
checking for gcc... (cached) clang
checking whether we are using the GNU C compiler... (cached) yes
checking whether clang accepts -g... (cached) yes
checking for clang option to accept ISO C89... (cached) none needed
checking for libpng-config... no
checking libpng... 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 png.h usability... no
checking png.h presence... no
checking for png.h... no
checking for png_read_update_info in -lpng... no
configure: libpng header and lib found
configure: using libpng dynamic linkage
checking for X... no
configure: error: X11 not found but required,configure aborted.
ERROR: configuration Failed for package ‘rgl’
* removing ‘/Library/Frameworks/R.framework/Versions/3.5/Resources/library/rgl’
* restoring prevIoUs ‘/Library/Frameworks/R.framework/Versions/3.5/Resources/library/rgl’
Warning in install.packages :
  installation of package ‘rgl’ had non-zero exit status

The downloaded source packages are in
    ‘/private/var/folders/yl/tb3dwr4x5gd79c_lbr_krp9h0000gn/T/RtmpK9gAxy/downloaded_packages’
> library(rgl)
Error in dyn.load(file,which you can download from xquartz.org.

这是怎么回事?这是否与无法加载broommicedlookr有关?感谢您的帮助!

编辑

我重新下载了R,现在mice加载正常;但是dlookrrgl仍然不会。

> library(dlookr)
Error: package or namespace load Failed for ‘dlookr’:
 .onLoad Failed in loadNamespace() for 'tcltk',details:
  call: fun(libname,pkgname)
  error: X11 library is missing: install XQuartz from xquartz.macosforge.org

> library(rgl)
Error in dyn.load(file,...) : 
  unable to load shared object '/Library/Frameworks/R.framework/Versions/4.0/Resources/library/rgl/libs/rgl.so':
  dlopen(/Library/Frameworks/R.framework/Versions/4.0/Resources/library/rgl/libs/rgl.so,6): Library not loaded: /opt/X11/lib/libglu.1.dylib
  Referenced from: /Library/Frameworks/R.framework/Versions/4.0/Resources/library/rgl/libs/rgl.so
  Reason: image not found
Error: package or namespace load Failed for ‘rgl’:
 .onLoad Failed in loadNamespace() for 'rgl',which you can download from xquartz.org.

我尝试下载XQuartz,但是:

> install.packages("XQuartz")
Warning in install.packages :
  package ‘XQuartz’ is not available (for R version 4.0.2)

我需要返回并安装旧版本的R才能使其正常工作吗?

解决方法

看来我需要从xquartz.org下载并安装XQuartz,才能使其中一些软件包在MAC上运行。

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。