I've got a linux server running RStudio, and I'm trying to connect to an SQL Anywhere database.
I have the drivers installed and configured, and I can connect using iSQL. When trying through RStudio, I continually get this error:
Error: nanodbc/nanodbc.cpp:983: 00000: [unixODBC][Driver Manager]Driver's SQLAllocHandle on SQL_HANDLE_HENV failed
However, if I launch an R script straight from /opt/bin/r/rscript, it connects.
The same thing happens when trying to connect with Python through a conda environment in my home directory. However, if I launch by typing "python test.py" into the terminal, the connection succeeds.
I'm on Ubuntu 18.04 with the SQL Anywhere 17 drivers. Any ideas would be appriciated.
Thanks.
I just solved this issue with a very similar setup: Connecting to a SQL Anywhere database, where the connection works from R when launched from the command line, but not from RStudio, and gives the error:
SQLAllocHandle on SQL_HANDLE_HENV failed
The key was to set the environment variables in RStudio to match those in my regular shell. In my case, these were $ODBCINI and $LD_LIBRARY_PATH. I reset them as follows:
In the shell, ran the following to get the values being used by console R.
echo $ODBCINI
echo $LD_LIBRARY_PATH
In RStudio, ran Sys.getenv() to confirm these values were different.
Reset the variables to match with
Sys.setenv(ODBCINI = "[path from shell]/odbc.ini")
Sys.setenv("LD_LIBRARY_PATH" = paste0(Sys.getenv("LD_LIBRARY_PATH"),":[user path from shell]"))
With this setup, I was able to connect from RStudio.
I was having this same error message with my new M1 Mac when I tried to connect with SQLite from RStudio. The RStudio solutions manual (https://solutions.rstudio.com/db/best-practices/drivers/) still only lists connection strings for odbc.ini and odbcinst.ini on an Intel Macs. When I changed my SQLite Driver in odbcinst.ini (located in /opt/homebrew/etc) after the Homebrew install to /opt/homebrew/lib/libsqlite3odbc.dylib instead of /usr/local/lib/libsqlite3odbc.dylib, it finally worked.
Related
I'm an Ubuntu user and I used to work with the standard version of Rstudio on my computer. After reading about the server version I installed it on my PC and I'm working with it now. Although I'm very happy with rstudio-server version, I have been facing some difficulties to keep with some old practices. Particularly, I use to launch, open and create new files from the terminal using rstudio keyword - I'm specially fond to the possibility of open files in current rstudio session through the terminal window within rstudio. However, I cannot figure out which command is equivalent in rstudio-server.
I tried, without success, the following commands:
rstudio-server
and
r-server
Interestingly, when I type which rstudio (to find the path of the program's binary files), the terminal did not return any results. The program is installed and working normally, but I just can't find it on my PC
Any help will be appreciated
I got my connection from R to a MS SQL Server database working on a Mac. I was able to get the right driver for the connection string by issuing the odbcListDrivers() command. However, I don't know if it was there or not before I started installing things like freetds and brew install --no-sandbox msodbcsql17 mssql-tools.
What I'd like to know is: with the odbcListDrivers(), how do I know what the file is it pulls from (a .ini one, I'm thinking)? I struggled because the configuration files I configured for freetds and another odbc.ini file don't affect what R is reading I believe, and made troubleshooting difficult.
In case I need to configure more drivers or DSN (?) entries.
I am troubleshooting an issue that I am running into on a new instance of RStudio on a virtual machine. If I run an R script expFit.R in RStudio, it has no problem finding the needed packages (in this case RODBC and minpack.lm) but if I try to run from the command line
c:\"Program Files"\R\R-3.4.1\bin\x64\Rscript.exe e:\expFit.R
I get the error 'minpack.lm' is not a valid installed package. If I move RODBC to be the first package to load, then it errors on that.
The reason that I am running from command line is that in the real application I am running it from a command line stored procedure in SQL. It doesn't work either way (stored procedure or straight command line). I made sure that the path to the packages is a Path variable.
This works on 2 of my other servers, the only difference being that RStudio is installed so that all users can use it on the server that is getting the error, while the other servers have it installed only in my account.
Any advice would be much appreciated!
When I login to RStudio server installed as an Amazon Machine Image, I, I see the message "RStudio Server Initialization Error" and "Status code 500 returned," as in the screenshot. When I click OK, nothing changes.
What does this mean and how can I fix this?
Refer the following link. It will guide you about the complete installation of R-Studio Server along with required dependencies.
Automated Installation of R-Studio Using Shell Script
It would be useful if you could state which version of RStudio Server you are using. Neverthless, you can try the following:
Install the most recent version using: wget http://download2.rstudio.org/rstudio-server-0.98.1103-amd64.deb. If you want 32-bit version wget http://download2.rstudio.org/rstudio-server-0.98.1103-i386.deb.
Delete the startup files (.Rprofile, .Renviron, and .RData) from your initial working directory, which should be user's home.
Check if you can run R from command line and if your are getting any error messages - fix that first
I am trying to execute a simple db2 command in Linux command prompt. but Linux command prompt is not recognizing the command it is giving - bash db2 command not found. but db2 is installed in the Linux machine.
command I am trying to execute from Linux command line processor is db2 "create database smaple"
Error I am getting is below "If db2 in not a typo you can run the following command to lookup the package that contains the binary" command-not-found db2 -bash: db2: command not found"
Is this because of environment variable problem ?? or there is only one instance of db2 ie db2inst1 is running in the machine.my user name in appsusr and db2 instance name is db2inst1 are different is this causing problem?? and I am not having super user access.Is this is causing any problem?? do I need super user access is required ??
Just type, echo $PATH in your command prompt , where you can see all the exported paths in your system.
If the db2 path is not found in your environment variable list, then do the following.
export PATH=$PATH:/opt/IBM/db2/V10.1/bin
and then press enter.
I hope this will resolve your issue.
On Linux and UNIX DB2 platforms, the proper way to set your environment variables to run DB2 commands is to source the sqllib/db2profile script belonging to the local DB2 instance owner. That will set not only your PATH but also other important variables that DB2 requires.
In your case, the instance is owned by the db2inst1 user, so your login startup file or batch script should run this command:
. ~db2inst1/sqllib/db2profile
The leading dot is necessary to set the variables in your current shell process, not the sub-process that quickly vanishes after db2profile finishes.
It's more than likely that, if DB2 is installed, it's simply not in your path.
Your path should contain something like:
/opt/IBM/db2/V10.1/bin
which is where the executables live (depending on which version you're running).
Changing your path will probably entail changes to one of the startup files, such as .bashrc or .bash_profile.