Skip to content

Instantly share code, notes, and snippets.

@jgilfillan
Last active December 21, 2021 17:35
Show Gist options
  • Save jgilfillan/7b0281067ed9feb4a71c to your computer and use it in GitHub Desktop.
Save jgilfillan/7b0281067ed9feb4a71c to your computer and use it in GitHub Desktop.
Instructions on how to install ROracle for R on Windows.

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.1-11.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")
# NOTE: never store passwords in a saved script!!
con <- dbConnect(drv, "USER GOES HERE", "PASSWORD GOES HERE", dbname='XXX')

test connection:

dbReadTable(con, 'DUAL')
@SophiaLC
Copy link

SophiaLC commented Aug 1, 2017

Installing Oracle Client on my computer fixed this issue.

@tjvananne
Copy link

For anyone else having trouble installing ROracle, the installation instructions on CRAN are actually very good and the links appear to all be working at the time of posting this. http://cran.us.r-project.org/web/packages/ROracle/INSTALL

@Chicago-Dave
Copy link

True, the CRAN instructions and error resolution page is quite extensive. Thanks for the link. However, I am experiencing the same issue and the error message I get does not match precisely any of those on the page.

"Error: package or namespace load failed for ‘ROracle’ in inDL(x, as.logical(local), as.logical(now), ...):
unable to load shared object '//SomeUniversity/HOME/R/win-library/3.4/ROracle/libs/x64/ROracle.dll':
LoadLibrary failure: The specified module could not be found."

The file is in the directory, compiled in x64 and running x64; Anyone know if the function 'inDL' is part of ROracle? DBI?

@baconrpatrick
Copy link

Your instructions are very clear and easy to follow. Thanks

@gmonteeiro
Copy link

Installing Oracle Client on my computer fixed this issue.

@adc91
Copy link

adc91 commented Mar 18, 2018

@gmonteeiro just that you had to install it or did you need some extra configuration? Because it still does not work :(

@siddhesh1991
Copy link

ROracle is not working with new version 3.5.0. Do you know why ?

@ofaakye
Copy link

ofaakye commented May 3, 2018

@siddhesh1991 ROracle is not working for as well on the new R 3.5.0. Did you find any solutions?

@tlorusso
Copy link

tlorusso commented Jun 6, 2018

Same here. I've just installed R 3.5.0 - and i get an error when loading the package:

Error: package or namespace load failed for ‘ROracle’:
 package ‘ROracle’ was installed by an R version with different internals; it needs to be reinstalled for use with this R version

Has anyone found a solution to this?

@siddhesh1991
Copy link

library('ROracle')
Loading required package: DBI Error: package or namespace load failed for ‘ROracle’: package ‘ROracle’ was installed by an R version with different internals; it needs to be reinstalled for use with this R version

R version 3.5.0 (2018-04-23) -- "Joy in Playing"

ROracle is not working with the new version of R, Can anyone help ?

@turingDH
Copy link

We looked everywhere for a solution, to no avail...had to roll back to 3.4. Thanks Larry E 👎

@jssasan
Copy link

jssasan commented Oct 15, 2018

Hello,

I had similar error. Here are few things that I have done to make it work successfully on windows X-64 machine.

  1. Downloaded Oracle instant client and unzipped it (copy its path). Then added a new variable in the existing Path variable (under System Variables), paste this path here.
  2. Uninstalled all R versions.
  3. Reinstalled R (Version R-3.5.1)
  4. Downloaded ROracle package (ROracle_1.3-1.zip) from https://www.oracle.com/technetwork/database/database-technologies/r/roracle/downloads/index.html . Save the downloaded zip file
  5. Open RStudio (or whatever you use) and run the below:
install.packages("C:\\Users\\username\\Desktop\\Software\\R\\ROracle_1.3-1.zip")   
library("ROracle")

Then ROracle got installed correctly. Make sure you are installing the downloaded package from step-3

Let me know if it still doesn't work. Happy to help!

@codrin-kruijne
Copy link

Hi @jssasan, when following your steps I get the following error:

Warning in install.packages : package ‘C:\Users\codrin_kruijne\Documents\ROracle\ROracle_1.3-1.zip’ is not available (for R version 3.5.1)

so I set the repos to NULL:

install.packages("C:\\Users\\codrin_kruijne\\Documents\\ROracle\\ROracle_1.3-1.zip", repos = NULL) Installing package into ‘C:/Users/codrin_kruijne/Documents/R/win-library/3.5’ (as ‘lib’ is unspecified) package ‘ROracle’ successfully unpacked and MD5 sums checked

but when I try to load it I get the following error:

library(ROracle) Loading required package: DBI Error: package or namespace load failed for ‘ROracle’: package ‘ROracle’ was installed by an R version with different internals; it needs to be reinstalled for use with this R version

so I downloaded RTools to recompile it from the source on CRAN:

install.packages("ROracle")
Installing package into ‘C:/Users/codrin_kruijne/Documents/R/win-library/3.5’
(as ‘lib’ is unspecified)
Package which is only available in source form, and may need compilation of
  C/C++/Fortran: ‘ROracle’
installing the source package ‘ROracle’

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

* installing *source* package 'ROracle' ...
** package 'ROracle' successfully unpacked and MD5 sums checked
Oracle Client Shared Library 64-bit - 18.3.0.0.0 Operating in Instant Client mode.
found Oracle Client C:\Users\codrin_kruijne\Documents\ROracle\instantclient_18_3
found Oracle Client include C:\Users\codrin_kruijne\Documents\ROracle\instantclient_18_3\sdk\include
copying from C:\Users\codrin_kruijne\Documents\ROracle\instantclient_18_3\sdk\include
** libs
Warning: this package has a non-empty 'configure.win' file,
so building only the main architecture

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.
make: *** [C:/PROGRA~1/R/R-35~1.1/etc/x64/Makeconf:208: rodbi.o] Error 1
ERROR: compilation failed for package 'ROracle'
* removing 'C:/Users/codrin_kruijne/Documents/R/win-library/3.5/ROracle'
* restoring previous 'C:/Users/codrin_kruijne/Documents/R/win-library/3.5/ROracle'
In R CMD INSTALL
Warning in install.packages :
  installation of package ‘ROracle’ had non-zero exit status

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

Can you help? Thanks!

@AlbertoCamposSilva
Copy link

Installation of ROracle is a bit tricky.

  1. Download ROracle package on your PC: https://www.oracle.com/database/technologies/roracle-downloads.html
    Download the tar.gz package!

  2. Access the INSTALL file on ROracle sub-directory and follow the instructions. The installation differs if you have or not Oracle installed on your machine.

Good instructions in: # https://medium.com/analytics-vidhya/how-to-install-roracle-on-windows-10-144b0b923dac

IMPORTANT

ROracle can't be directly installed on R4+

So, download ROracle package on your PC: https://www.oracle.com/database/technologies/roracle-downloads.html
Download the tar.gz package!

Install it on your RStudio with the following command:

install.packages('C:\Downloads\ROracle_1.3-2.tar.gz', repos = NULL, type="source")

Don't forget to correct the directory in which you've downloaded the file. This will recompile your package to version 4 of R.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment