在 OSX 上为 R 安装 RForge 版本的 xts 包时出错

发布于 2024-10-18 14:59:56 字数 2226 浏览 2 评论 0原文

CRAN上xts的最新版本是0.7-5。但我想尝试一下 blotter 包,它需要 xts >= 0.7.6.17 。为了获得这个最新版本,我首先从 RForge 下载了 .tgz 文件并尝试:

[Downloads]$ R CMD INSTALL xts_0.7-6.17.tgz 
WARNING: ignoring environment value of R_HOME
* installing to library ‘/Library/Frameworks/R.framework/Resources/library’
* installing *binary* package ‘xts’ ...

* DONE (xts)

启动 R 控制台后,我输入 require(xts) 并得到这个:

> require(xts)
Loading required package: xts
Loading required package: zoo
Error in dyn.load(file, DLLpath = DLLpath, ...) : 
unable to load shared object '/Library/Frameworks/R.framework/Versions/2.12/Resources/library/xts/libs/x86_64/xts.so':
dlopen(/Library/Frameworks/R.framework/Versions/2.12/Resources/library/xts/libs/x86_64/xts.so, 6): Library not loaded: /usr/local/lib/libgfortran.2.dylib
Referenced from: /Library/Frameworks/R.framework/Versions/2.12/Resources/library/xts/libs/x86_64/xts.so
Reason: image not found
In addition: Warning message:
package 'xts' was built under R version 2.12.2 

通过下载该文件并再次运行它来恢复到 CRAN 版本:

[Downloads]$ R CMD INSTALL xts_0.7-5.tgz 
WARNING: ignoring environment value of R_HOME
* installing to library ‘/Library/Frameworks/R.framework/Resources/library’
* installing *binary* package ‘xts’ ...

* DONE (xts)

我 R 控制台并输入 require(xts):

> require(xts)
Loading required package: xts
Loading required package: zoo
>

一切都很好,除了我需要 RForge 版本来安装 blotter。

注意:我正在运行 OS X (10.6.6)

更新:一切都不太好。现在我无法正确加载 CRAN xts 版本。

更新#2:我通过运行 install.packages("xts", repo="http://cran.r-project.org") 找回了旧的 xts。实际上,我也为“quantmod”和“TTR”运行了它,因为正在发生各种神秘的破坏。

遇到了

make: gfortran: No such file or directory

更新#3:按照下面评论中 Dirk 的建议,我尝试在 OS X 上从源代码进行编译,并在从 http://www.macresearch.org/xcode_gfortran_plugin_update,我现在面临一个新的错误,抱怨 -arch 标志:

gfortran -arch i386   -fPIC  -g -O2 -c period.max.f -o period.max.o
f951: error: unrecognized command line option "-arch"

UPDATE #4:我在 UPDATE 中安装了错误的 fortran 编译器#3。不要将该编译器用于 R 包。

The latest version of xts on CRAN is 0.7-5. But I'd like to try out the blotter package, for which xts >= 0.7.6.17 is required. To get this latest version, I first I downloaded the .tgz file from RForge and tried:

[Downloads]$ R CMD INSTALL xts_0.7-6.17.tgz 
WARNING: ignoring environment value of R_HOME
* installing to library ‘/Library/Frameworks/R.framework/Resources/library’
* installing *binary* package ‘xts’ ...

* DONE (xts)

After launching R console, I typed require(xts) and got this:

> require(xts)
Loading required package: xts
Loading required package: zoo
Error in dyn.load(file, DLLpath = DLLpath, ...) : 
unable to load shared object '/Library/Frameworks/R.framework/Versions/2.12/Resources/library/xts/libs/x86_64/xts.so':
dlopen(/Library/Frameworks/R.framework/Versions/2.12/Resources/library/xts/libs/x86_64/xts.so, 6): Library not loaded: /usr/local/lib/libgfortran.2.dylib
Referenced from: /Library/Frameworks/R.framework/Versions/2.12/Resources/library/xts/libs/x86_64/xts.so
Reason: image not found
In addition: Warning message:
package 'xts' was built under R version 2.12.2 

I reverted to the CRAN version by downloading that file and running this again:

[Downloads]$ R CMD INSTALL xts_0.7-5.tgz 
WARNING: ignoring environment value of R_HOME
* installing to library ‘/Library/Frameworks/R.framework/Resources/library’
* installing *binary* package ‘xts’ ...

* DONE (xts)

Opening R console and typing in require(xts):

> require(xts)
Loading required package: xts
Loading required package: zoo
>

All is well again, except I need to RForge version to get blotter installed.

NOTE: I'm running OS X (10.6.6)

UPDATE: all is NOT well. Now I can't get the CRAN xts version to load properly.

UPDATE #2: I got my old xts back by running install.packages("xts", repo="http://cran.r-project.org"). Actually, I ran it for "quantmod" and "TTR" as well because all manner of mysterious breaking was occurring.

UPDATE #3: Following Dirk's recommendation in comments below, I've attempted to compile from source on OS X and was met with

make: gfortran: No such file or directory

So after installing from the link at http://www.macresearch.org/xcode_gfortran_plugin_update, I'm now faced with a new error complaining about the -arch flag:

gfortran -arch i386   -fPIC  -g -O2 -c period.max.f -o period.max.o
f951: error: unrecognized command line option "-arch"

UPDATE #4: I installed the wrong fortran compiler in UPDATE #3. Don't use that compiler for R packages.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

往日 2024-10-25 14:59:56

如果您在 Mac OS X 平台上使用 R,那么最好了解从源代码安装的机制,因为 Mac 二进制文件有时加载到存储库的速度很慢。 R 生态系统是 Ubuntu 和 SVN。有一天它可能会转变为 OS X 和 Git(我们希望如此,不是吗?)

在开始从源代码安装之前,您需要确保已安装 Xcode。

http://developer.apple.com/technologies/tools/xcode.html

然后你需要有一个 fortran 编译器,它不随 Xcode 一起提供。好消息是 OS X 上有一个专门为 R 用户提供 fortran 编译器的地方。

http://r.research.att.com/tools/

安装并配置后正确地,您需要从这里获取 RForge 的 xts 的尖端版本:(感谢 Dirk)

http://r-forge.r-project.org/src/contrib/xts_0.7-6.17.tar.gz

最后,只需从命令运行以下命令- 终端中的行:

[Downloads]$ R CMD INSTALL xts_0.7-6.17.tar.gz

注意:tar.gz 是源文件的扩展名,而 .tgz 是 Mac 二进制文件的扩展名。

If you are using R on the Mac OS X platform, then it's good to know the mechanics of installing from source, as Mac binaries are sometimes slow to make it to repositories. The R eco-system is Ubuntu and SVN. Someday it may morph to OS X and Git (we can hope, no?)

Before you start installing from source, you need to make sure you have Xcode installed.

http://developer.apple.com/technologies/tools/xcode.html

Then you need to have a fortran compiler, which doesn't come with Xcode. The good news is that there is a place devoted to fortran compilers on OS X for R users.

http://r.research.att.com/tools/

Once this is installed and configured properly, you need to get the cutting-edge version of xts from RForge from here: (Thanks Dirk)

http://r-forge.r-project.org/src/contrib/xts_0.7-6.17.tar.gz

Finally, simply run the following from command-line in terminal:

[Downloads]$ R CMD INSTALL xts_0.7-6.17.tar.gz

NOTE: tar.gz is the extension for source files while .tgz is the extension for Mac binaries.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文