rPython using wrong python installation on Mac OSX
Question: I've installed python 2.7.8 alongside the 2.7.5 which comes with OSX 10.9.4.

Now how can I point `rPython` to python 2.7.8?

## Attempt #1

I've modified the OSX `.bash_profile` as follows to point everything to the
newer python installation.

    
    
    export PATH=/usr/local/Cellar/python/2.7.8/bin/:$PATH:usr/local/bin:
    

And now when I run python from the terminal, it correctly runs the newer
version

    
    
    mba:~ tommy$ which python
    /usr/local/Cellar/python/2.7.8/bin//python
    

However, `rPython`, still sees 2.7.5.

    
    
    > library(rPython)
    Loading required package: RJSONIO
    > python.exec("import sys; print(sys.version)")
    2.7.5 (default, Mar  9 2014, 22:15:05) 
    [GCC 4.2.1 Compatible Apple LLVM 5.0 (clang-500.0.68)]
    

## Attempt #2

It looks like the `.bash_profile` doesn't get used by R at all... so I've
tried to modify the PATH within R. But still no luck.

    
    
    > Sys.getenv("PATH")
    [1] "/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin"
    > Sys.setenv(PATH = "usr/local/Cellar/python/2.7.8/bin")
    > library(rPython)
    Loading required package: RJSONIO
    > python.exec("import sys; print(sys.version)")
    2.7.5 (default, Mar  9 2014, 22:15:05) 
    [GCC 4.2.1 Compatible Apple LLVM 5.0 (clang-500.0.68)]
    

## Attempt #3

I tried removing and re-installing the `rPython` package thinking perhaps it
was using the version of Python that it found upon installation. No luck
either.

## Attempt #4

I've tried installing from source to see if that does anything... no luck.

# Update

Okay so it looks like the problem isn't anything to do with rPython itself.

<http://cran.r-project.org/web/packages/rPython/INSTALL>

> Package rPython depends on Python (>= 2.7).
>
> It requires both Python and its headers and libraries. These can be found in
> python and python-dev packages in Debian-like Linux distributions.
>
> 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

When I run that in the terminal..

    
    
    mba:src tommy$ python --version
    Python 2.7.8
    

But when I run it in R...

    
    
    > system("python --version")
    Python 2.7.5
    

So the problem is simply that R doesn't use OSX's `.bash_profile`. I'll need
to figure out how to change `PATH` outside of `.bash_profile`, or get R to use
`.bash_profile`.

What else can I try to get `rPython` working with `2.7.8`?


Answer: You can have a look at the rPython INSTALL file (sorry, perhaps I should make
it more explicit). It has a section on how to install rPython using the
desired Python version when several coexists. It says:

> 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 RPYTHON_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.

