在 MacOS 上安装 ROracle(和 Oracle Instant Client?)
Installing ROracle (and the Oracle Instant Client?) on MacOS
我正在尝试安装 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 中并使用自制软件安装它们。
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 有什么问题吗?我应该如何处理这些信息?
适用于 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
可以在 Intall ROracle Package for Windows and Mac OS
上找到没有 -add_rpath
的解决方案
我使用 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 后只有 link 到 libclntsh.dylib.12.1' is needed. But it does not harm to create the others as well. This way you do not need to run
install_name_tool`。
创建 links 后,我可以使用 R CMD INSTALL
安装 ROracle
我正在尝试安装 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 中并使用自制软件安装它们。
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 有什么问题吗?我应该如何处理这些信息?
适用于 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
可以在 Intall ROracle Package for Windows and Mac OS
上找到没有-add_rpath
的解决方案
我使用 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 后只有 link 到 libclntsh.dylib.12.1' is needed. But it does not harm to create the others as well. This way you do not need to run
install_name_tool`。
创建 links 后,我可以使用 R CMD INSTALL