How to Install Roracle Package on Windows 7

How to install ROracle package?

from a past post.
How to install ROracle package on 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')

was able to install from source and download the pre compiled addin directly from oracle

ROracle install

Download compatible versions of ROracle, Instant Client & R

LATEST version of RTools can be downloaded from link below

Important links:
Instant Client Version (12.2): Download the basic as well sdk version of instant client
http://www.oracle.com/technetwork/database/features/instant-client/

R for Windows (Look for previous releases of R for Windows)
https://cran.rstudio.com/bin/windows/base/old/
https://cran.rstudio.com/bin/windows/base/old/3.6.1/R-3.6.1-win.exe

RTools (RTools35)
https://cran.r-project.org/bin/windows/Rtools/

ROracle (ROracle-1.3.2 is compatible with R3.6.0 version and above)
https://www.oracle.com/database/technologies/roracle-downloads.html
Very important link for Troubleshooting ROracle: https://cran.cnr.berkeley.edu/web/packages/ROracle/INSTALL

RStudio

Set the below environment variables in control Panel > System & Security > System> Advanced System Settings> In System properties, click on "Environment Variables"> In system variables SET BELOW:

ORACLE_HOME = 'C:/oreclient_install_dir/instantclient_12_2'
OCI_INC = 'C:/oreclient_install_dir/instantclient_12_2/sdk/include'
OCI_LIB64 = 'C:/oreclient_install_dir/instantclient_12_2'
TNS_ADMIN = 'C:/oreclient_install_dir/instantclient_12_2'

Please see I have installed 64-bit version of R and hence setting environment variables for the same. If you are using 32-bit version, please set OCI_LIB32 with appropriate path. Also, place the TNS file at the appropriate location.

Also, set path to include:

C:\oreclient_install_dir\instantclient_12_2 <br/>
C:\app\client\pc_username\product\12.2.0\client_1
C:\app\client\pc_username\product\12.2.0\client_1\bin
C:\app\client\pc_username\product\12.2.0\client_1\Network\Admin
%PATH%
C:\R\R-3.6.0\bin
C:\R\Rtools\bin
C:\R\Rtools\mingw_64\bin

Few important R commands to check the variables set:

R.home(component = "home")
Sys.getenv("PATH")
Sys.getenv("OCI_INC")
Sys.getenv("OCI_LIB64")
Sys.getenv("ORACLE_HOME")
Sys.getenv("TNS_ADMIN")

Please re-start R when the env variables are set and it is recommended to run R as administrator when running ROracle commands.

install.packages("C:/ROracle/ROracle_1.3-2.tar.gz", repos = NULL)

you may need to install DBI package as well

install.packages("DBI")
library("DBI")
library("ROracle")

Installing ROracle

You need to follow the following procedure:

  1. Create a folder called "ROracle" and put the downloaded zip ROracle-1.3.2.zip in there
  2. Unzip the .zip file in the folder. Now you have all the contents of the zip file (including the original zip file) in the ROracle folder that you created in step 1
  3. Remove the original .zip file from the folder. Now the folder "ROracle" you created in step 1 only contains the contents of the original .zip file
  4. Add the "ROracle" folder to a zip file called "ROracle.zip"

Got down into this solution by comparing hierarchy of earlier ROracle_1.3-1.zip -file which i got working well in earlier R version.

After following all these steps the outcome is that the DESCRIPTION file can be found in ROracle.zip/ROracle/DESCRIPTION instead of ROracle-1.3.2.zip/DESCRIPTION

With the newly zip-file from step 4 the installation is a quite straightforward.

setwd("THEPLACEWHERETHE ROracle.zip file is located)
install.packages('ROracle.zip', repos = NULL)

My .Renviron contains these lines if that matters

    # PATH="C:/Rtools/bin;C:/oracle/instantclient_19_5;$PATH"
# OCI_LIB64 = C:/oracle/instantclient_19_5
# BINPREF="C:/Rtools/mingw_$(WIN)/bin/"

OS is WIN10.
R version 3.6.2 (2019-12-12) -- "Dark and Stormy Night"
Platform: x86_64-w64-mingw32/x64 (64-bit)
ROracle 1.3-2

How to install ROracle on R 4.1.3

Have a look at the installation guide. It has the following steps for windows:

  13.Add the full path of the Instant Client to the environment variables 
OCI_LIB64 and PATH.

The following steps set the variables to the PATH used in this example,
c:\myoreclient\instantclient_11_2.
1. In Windows Control Panel, select System, then click Advanced system
settings.
2. On the Advanced tab, click Environment Variables.
3. Under System variables, create OCI_LIB64 if it does not already exist.
4. Set the value of OCI_LIB64 to c:\oreclient\instantclient_11_2.
5. Under System variables, edit PATH to include
c:\oreclient\instantclient_11_2.

ROracle package installation failure

I had the exact same problem:

c:/Rtools/mingw_64/bin/gcc  -I"C:/PROGRA~1/R/R-35~1.1/include" -DNDEBUG -I./oci         -O2 -Wall  -std=gnu99 -mtune=generic -c rodbi.c -o rodbi.o
In file included from rooci.h:75:0,
from rodbi.c:181:
./oci/oci.h:716:20: fatal error: ociver.h: No such file or directory
#include <ociver.h>
^
compilation terminated.

Once I looked a lot closer to the error I realized what was happening. It looked to me that the arguments for Rtools was setting -I to R's include folder, not the OCI include folder, and guess what isn't in R's include folder? That's right, ociver.h. I believe R tries to copy the contents of the OCI include folder to the R include folder because of this line a few lines up from the error:

copying from C:\Oracle\instantclient_18_3\sdk\include\

and fails maybe running as administrator will help? Or perhaps editing folder permissions?

Anyway, I manually copied the contents of the oracle include folder to the R include folder and that seemed to fix the problem for me.



Related Topics



Leave a reply



Submit