How to install ROracle package on Windows 7?

2019-01-21 20:20发布

I'm trying to install ROracle package on my Windows 7 client. I have Oracle Instant client and Rtools installed, DBI package is istalled, OCI32_LIB environmental variable has been set. But when I try to install from command line:

C:\Temp>R CMD INSTALL --build ROracle_1.1-10.tar.gz
* installing to library 'C:/Users/myaccount/Documents/R/win-library/3.0'
* installing *source* package 'ROracle' ...
** package 'ROracle' successfully unpacked and MD5 sums checked
ERROR: configuration failed for package 'ROracle'
* removing 'C:/Users/myaccount/Documents/R/win-library/3.0/ROracle'

C:\Temp>

When I try to install from source:

> install.packages("ROracle",type = "source")
Warning in install.packages :
  package ‘ROracle’ is not available (for R version 3.0.0)
Installing package into ‘C:/Users/myaccount/Documents/R/win-library/3.0’
(as ‘lib’ is unspecified)
trying URL 'http://cran.at.r-project.org/src/contrib/ROracle_1.1-10.tar.gz'
Content type 'application/x-gzip' length 168193 bytes (164 Kb)
opened URL
downloaded 164 Kb

* installing *source* package 'ROracle' ...
** package 'ROracle' successfully unpacked and MD5 sums checked
ERROR: configuration failed for package 'ROracle'
* removing 'C:/Users/myaccount/Documents/R/win-library/3.0/ROracle'
Warning in install.packages :
  running command '"C:/PROGRA~1/R/R-30~1.0/bin/i386/R" CMD INSTALL -l "C:\Users\myaccount\Documents\R\win-library\3.0" C:\Users\myaccount\AppData\Local\Temp\RtmpGggbyp/downloaded_packages/ROracle_1.1-10.tar.gz' had status 1
Warning in install.packages :
  installation of package ‘ROracle’ had non-zero exit status

The downloaded source packages are in
    ‘C:\Users\myaccount\AppData\Local\Temp\RtmpGggbyp\downloaded_packages’

What should I do, how to proceed?

6条回答
Juvenile、少年°
2楼-- · 2019-01-21 20:27

Along with the 'Basic Package' and the 'ODBC Package', with Oracle 11g, you should copy unpacked files from the 'SDK package' into the subdirectory instantclient_11_2. In this case, you will not need to define the environment variable Sys.setenv (OCI_INC = "...").

查看更多
手持菜刀,她持情操
3楼-- · 2019-01-21 20:34

I had this exact problem as well, including the OCI_INC error. They actually talk about it in the INSTALL file in the .tar.gz package, you can read more there.

You have to set the OCI_INC variable to the include directory like this:

set OCI_INC=C:\oracle\product\11.2.0\client_2\oci\include

Or whereever your file is. Here was my complete setup to get things installed from an Admin privileged command line.

set OCI_LIB64=C:\oracle\product\11.2.0\client_2\BIN
set OCI_INC=C:\oracle\product\11.2.0\client_2\oci\include
set PATH=C:\oracle\product\11.2.0\client_2\BIN;C:\Rtools\bin;c:\Rtools\gcc-4.6.3\bin;%PATH%
"C:/PROGRA~1/R/R-30~1.1/bin/x64/R" CMD INSTALL --build "C:/Your/Path/To/ROracle_1.1-10.tar.gz"

Also, make sure to change client_2 to client_1 and OCI_LIB64 to OCI_LIB32 if you are trying to do a 32-bit install.

查看更多
爱情/是我丢掉的垃圾
4楼-- · 2019-01-21 20:37

I had a similar error when trying to install ROracle from source.1

After searching around a bit I had to undertake what others have mentioned as well as redownloading the tar.gz. When I double checked the download size it was 10KB instead of 234KB.

  1. Re-Download source from: http://cran.r-project.org/web/packages/ROracle/index.html
  2. Updated the following Environmental Varibles in windows

    SET PATH=C:\Rtools\bin;C:\Rtools\gcc-4.6.3;%PATH% SET OCI_INC=C:\Oracle_11G_ClientR2\product\11.2.0\client_1\oci\include SET OCI_LIB32=C:\Oracle_11G_ClientR2\product\11.2.0\client_1\BIN SET OCI_LIB64=C:\Oracle_11G_ClientR2\product\11.2.0\client_1\BIN R CMD INSTALL --build "C:\temp\ROracle_1.1-12.tar.gz"

  3. Output should look like the following: samplecmdoutput

1 Here is what the previous error looked like:

C:\Temp>R CMD INSTALL --build "C:\\temp\\ROracle_1.1-12.tar.gz" 
Error in getOctD(x, offset, len) : invalid octal digit
查看更多
地球回转人心会变
5楼-- · 2019-01-21 20:42

I had exactly this problem. It was caused because when installing RTools I did not check the 'edit PATH' checkbox. I uninstalled RTools and reinstalled it again, this time making sure the checkbox was checked, and it worked first time! Hope this helps.

查看更多
甜甜的少女心
6楼-- · 2019-01-21 20:46

From http://jgilfillan.github.io/2016/05/28/how-to-install-roracle-in-windows-7/

Download binary from oracle: http://www.oracle.com/technetwork/database/database-technologies/r/roracle/downloads/index.html

The run the following command in r, substituting the file path:

setwd('xxxxx')   # set to path of download
install.packages('ROracle_1.2-1.zip', repos = NULL)

Then load the library and use the package - you may have to change XXXX to whatever is in your TNS Names:

library('ROracle')
drv <- dbDriver("Oracle")
con <- dbConnect(drv, "USER GOES HERE", "PASSWORD GOES HERE", dbname='XXX')

test connection:

dbReadTable(con, 'DUAL')

Note that this has also been confirmed to work on Windows 10.

查看更多
Explosion°爆炸
7楼-- · 2019-01-21 20:51

After following the steps (highlighted in red boxes). I also ran commands below on R. enter image description here enter image description here So, everything went through well on a Windows 7 64-bit, R 3.4 64bit environment. enter image description here enter image description here

Sys.setenv(OCI_LIB64="C:/Oracle/instantclient_12_2/")
Sys.setenv(OCI_INC="C:/Oracle/product/11.2.0/client_1/oci/include")
install.packages("ROracle", dep=T)
查看更多
登录 后发表回答