0

When I try and load the R extension using:

%load_ext rpy2.ipython

I get:

C:\Users\Robert.Levy\AppData\Local\Continuum\Anaconda2\lib\site-packages\rpy2\rinterface\__init__.py in <module>()
     14     R_HOME = (os.environ["R_HOME"], )
     15 except KeyError:
---> 16     tmp = subprocess.check_output(("R", "RHOME"), universal_newlines=True)
     17     R_HOME = tmp.split(os.linesep)
     18     del(tmp)

WindowsError: [Error 2] The system cannot find the file specified

I'm running Python 2.7.1 on Windows 10 with no admin rights.

I have R installed to a local directory username\Documents\R\... but due to lack of admin rights, there's no entry in my PATH and no environment variable called R_HOME.

I've added an account-level environment variable with this name, but os.environ seems not to pick these up.

How can I proceed?

LondonRob
  • 73,083
  • 37
  • 144
  • 201

1 Answers1

0

The Jupyter Notebook you interact with (in the browser) is really just a front-end on a process which runs in a command window. Restarting the kernel is not enough to "refresh" environment variables.

The window must be closed and a new one opened.

After setting your profile-level environment variable to:

C:\Users\{username}\Documents\R\R-3.4.1

shut down the kernel, making sure the command window closes, then restart Jupyter Notebook and the new environment variables will be available.

Note that you may also need to add an R_USER environment variable with your Windows username.

LondonRob
  • 73,083
  • 37
  • 144
  • 201