【问题标题】:Installing ROracle (and the Oracle Instant Client?) on MacOS在 MacOS 上安装 ROracle(和 Oracle Instant Client?)
【发布时间】:2018-05-29 00:18:14
【问题描述】:

我正在尝试安装 ROracle。由于 ROracle 需要 Oracle OCI 库,我从 Oracle 网站下载了这些文件:instantclient-basic-macos.x64-12.2.0.1.0、instantclient-sdk-macos.x64-12.2.0.1.0.zip。我将这些文件放入 ~/Library/Caches/Homebrew 并使用 homebrew 安装它们。

brew install instantclient-basic
brew install instantclient-sdk

Oracle网站也提到需要设置一些环境变量,所以我把这个放在我的.bashrc文件中:

export LD_LIBRARY_PATH=/usr/local/Cellar/instantclient-basiclite/12.2.0.1.0/lib:$LD_LIBRARY_PATH
export DYLD_LIBRARY_PATH=/usr/local/Cellar/instantclient-basiclite/12.2.0.1.0/lib:$DYLD_LIBRARY_PATH
export NLS_LANG=UTF8

但是尝试在 R 中安装 ROracle 会导致:

> install.packages("ROracle")
Installing package into ‘/usr/local/lib/R/3.4/site-library’
(as ‘lib’ is unspecified)
trying URL 'https://cran.rstudio.com/src/contrib/ROracle_1.3-1.tar.gz'
Content type 'application/x-gzip' length 308252 bytes (301 KB)
==================================================
downloaded 301 KB

Warning in strptime(xx, f <- "%Y-%m-%d %H:%M:%OS", tz = tz) :
unknown timezone 'zone/tz/2017c.1.0/zoneinfo/America/Los_Angeles'
* installing *source* package ‘ROracle’ ...
** package ‘ROracle’ successfully unpacked and MD5 sums checked
configure: error: OCI libraries not found
ERROR: configuration failed for package ‘ROracle’
* removing ‘/usr/local/lib/R/3.4/site-library/ROracle’
Warning in install.packages :
  installation of package ‘ROracle’ had non-zero exit status

R 说它找不到 OCI 库。到目前为止,Oracle 的文档已被证明在解决此问题方面不存在或毫无价值,但我找到了 comment on the internet that seemed promising。所以我把它写到我的 .bashrc 中并运行它:

R CMD INSTALL --configure-args='--with-oci-lib=/usr/local/Cellar/instantclient-basic/12.2.0.1.0/lib --with-oci-inc=/usr/local/Cellar/instantclient-sdk/12.2.0.1.0/lib/sdk/include' ROracle_1.3-1.tar.gz

有了这个结果:

installing to /usr/local/lib/R/3.4/site-library/ROracle/libs
** R
** inst
** preparing package for lazy loading
** help
*** installing help indices
** building package indices
** testing if installed package can be loaded
Error: package or namespace load failed for ‘ROracle’ in dyn.load(file, DLLpath = DLLpath, ...):
****unable to load shared object '/usr/local/lib/R/3.4/site-
library/ROracle/libs/ROracle.so':
    dlopen(/usr/local/lib/R/3.4/site-library/ROracle/libs/ROracle.so, 6): Symbol 
    not found: _ons_recvthread_clone_sb
  Referenced from: /usr/local/Cellar/instantclient-basic/12.2.0.1.0/lib/libons.dylib
  Expected in: flat namespace
 in /usr/local/Cellar/instantclient-basic/12.2.0.1.0/lib/libons.dylib
Error: loading failed
Execution halted
ERROR: loading failed
* removing ‘/usr/local/lib/R/3.4/site-library/ROracle’

所以 libons.dylib 有问题吗?我应该如何处理这些信息?

【问题讨论】:

  • 我通常会跟随软件包附带的installation instructions,这意味着我倾向于将基本和sdk软件包放在同一目录中,我符号链接libclntsh.dylib.12.1并仅使用oci-lib进行编译选项。
  • 我尝试重新安装所有内容,但现在出现错误,与上次非常相似,但显示以下消息:无法加载共享对象'/usr/local/lib/R/3.4/site -library/ROracle/libs/ROracle.so':dlopen(/usr/local/lib/R/3.4/site-library/ROracle/libs/ROracle.so, 6):库未加载:@rpath/libclntsh.dylib .12.1 引用自:/usr/local/lib/R/3.4/site-library/ROracle/libs/ROracle.so 原因:找不到图像
  • 您是否对那个文件进行了符号链接?看起来问题出在那儿。我从来没有(成功地)使用通过自制软件安装的即时客户端库安装 ROracle,我总是自己下载它们并自己手动解压缩它们。除此之外,我可能没有太多帮助。但我真的,真的同情。我以前经历过很多次。
  • 我确实按照说明创建了一个符号链接,尽管我使用的是即时客户端版本 12.2 而不是 12.1。我可能会尝试 12.1 看看它是否有效
  • 似乎是 community.oracle.com/thread/4092751 的副本,正在调查那里指出的 Oracle 错误。

标签: r oracle roracle


【解决方案1】:

适用于 macOS 的 Instant Client 12.2 已修补。从http://www.oracle.com/technetwork/topics/intel-macsoft-096467.html 获取并解压缩,例如到~/instantclient_12_2

我能够在 macOS 上安装 ROracle:

brew install R

更新库中的 rpath(使用正确的 R 版本号):

install_name_tool -add_rpath ~/instantclient_12_2 /usr/local/Cellar/r/3.4.3/lib/R/bin/exec/R

运行“R”,然后:

install.packages("DBI")

https://cran.r-project.org/web/packages/ROracle/index.html下载ROracle_1.3-1.tar.gz并安装:

R CMD INSTALL --configure-args='--with-oci-lib=/Users/cjones/instantclient_12_2  --with-oci-inc=/Users/cjones/instantclient_12_2/sdk/include' ROracle_1.3-1.tar.gz

【讨论】:

  • 我大约一个月前搁置了这个项目,但今天我终于使用本指南让 ROracle 在我的 mac 上工作。谢谢克里斯托弗!
  • 我尝试了您的解决方案,但我会得到:错误:dyn.load(file, DLLpath = DLLpath, ...) 中的 'ROracle' 的包或命名空间加载失败:无法加载共享对象' /usr/local/lib/R/3.5/site-library/ROracle/libs/ROracle.so': dlopen(/usr/local/lib/R/3.5/site-library/ROracle/libs/ROracle.so, 6 ):找不到符号:_OCIArrayDescriptorAlloc 引用自:/usr/local/lib/R/3.5/site-library/ROracle/libs/ROracle.so 预期在:/usr/local/lib/R/3.5/site 中的平面命名空间-library/ROracle/libs/ROracle.so 错误:加载失败 Esecuzione interrotta 错误:加载失败
【解决方案2】:

没有-add_rpath 的解决方案可以在Intall ROracle Package for Windows and Mac OS 上找到

我使用 Macports 的 R 并且确实做到了:

cd /opt/local/Library/Frameworks/R.framework/Resources/lib
sudo ln -s ~/Applications/instantclient/libclntsh.dylib.12.1
sudo ln -s ~/Applications/instantclient/libclntshcore.dylib.12.1
sudo ln -s libclntsh.dylib.12.1 libclntsh.dylib
sudo ln -s libclntshcore.dylib.12.1 libclntshcore.dylib

我认为每次升级到 R 后只有指向 libclntsh.dylib.12.1' is needed. But it does not harm to create the others as well. This way you do not need to runinstall_name_tool` 的链接。

创建链接后,我可以使用 R CMD INSTALL 安装 ROracle

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2016-10-09
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多