2

I have Anaconda installed in my system with Python 3.5. When I run:

$ which python 

in the terminal, it correctly shows the intended one i.e. the one within Anaconda. When typed:

$ python --version

it shows Python 3.5.3. Now when I installed the rPython package in R, it is taking the python from usr/bin/python which is Python 2.7.12.

How to set the correct python interpreter for R using rPython?

Thanks in advance

Benny
  • 4,790
  • 2
  • 18
  • 33
  • 4
    Possible duplicate of [How to make 'python' program command execute Python 3?](https://askubuntu.com/questions/320996/how-to-make-python-program-command-execute-python-3) – adadion Jun 21 '17 at 11:39
  • 1
    @adadion: I don't think that will help because that question doesn't deal with how to tell rPython about a different Python interpreter. See my answer. – David Foerster Jun 21 '17 at 13:06
  • great, even that will works too – adadion Jun 22 '17 at 06:49

1 Answers1

2

From the rPython INSTALL manual:

In systems where several Python versions coexist, the user can choose the Python version to use at installation time. By default, the package will be installed using the Python version given by

$ python --version

but it is possible to select a different one if the PYTHON_PYTHON_VERSION environment variable is appropriately set.

For instance, if it is defined as

RPYTHON_PYTHON_VERSION=3.2

it will try to use Python 3.2 (looking for python3.2 and python3.2-config in the path). If set to

RPYTHON_PYTHON_VERSION=3

it will install against the "canonical" Python version in the system within the 3.x branch.

Ergo, you need to start R with the environment variable RPYTHON_PYTHON_VERSION set to 3, e. g.:

RPYTHON_PYTHON_VERSION=3 R

The same applies if you're using R with some front-end.

David Foerster
  • 35,754
  • 55
  • 92
  • 145