Issue
I am running Jupyter notebook using VSCode. In order to run rpy2
, I have to insert the following code in my notebook:
import os
os.environ['R_HOME'] = '/Library/Frameworks/R.framework/Resources/'
I would prefer not to insert this into my scripts or notebooks every time as I am collaborating with others and I'm not sure if the above path is universal.
Anyway, I added the line
export R_HOME=/Library/Frameworks/R.framework/Resources/
in my .bash_profile and .zshrc. I already applied source to these configuration files. However, Jupyter notebook still complains.
How can I modify what os.environ
returns outside of my notebook? Can anyone direct me the path of the file that is being loaded by os.environ
? This way, I'll just export the variable R_HOME. I am using a conda environment too if that matters.
Advice greatly appreciated.
Solution
you can set environment variables for your conda environment, so create a .env
file in the root directory and add this line:
R_HOME=/Library/Frameworks/R.framework/Resources/
this will specifically set the R_HOME
variable for your conda environment, and also to find the loaded file path for os.environ
, you can use the inspect
module and modify that file to set the R_HOME
variable.
import inspect
import os
print(inspect.getfile(os))
Answered By - Freeman
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.