When you invoke either $ python --version
or $ Rscript -e 'system("python --version")'
from the shell command line, you are operating in a Python virtual environment, perhaps one created by virtualenv
. Specifically, you are executing /home/foo/miniconda3/bin/python
When you run system("python --version")
from RStudio, you get the system default version. Specifically, you are executing /usr/bin/python
.
How can I point my $ Rscript "foo.R"
calls to python 2.7.9?
That depends upon how you entered your virtual Python environment. If it was one created by virtualenv
, simply deactivate it:
$ deactivate
$ Rscript -e 'system("python --version")'
2.7.9
EDIT: You appear to be using virtual environments created by miniconda. If that is the case, you can use the system default Python by editing your PATH environment variable. How you edit your PATH depends upon how long you want your change to have effect.
For your change to lost for only a single command, try this:
$ PATH="$(echo "$PATH" | sed -e s,:/usr/local/sbin,,)" Rscript -e 'system("python --version")'
For your change to last the duration of a single shell session, try this:
$ PATH="$(echo "$PATH" | sed -e s,:/usr/local/sbin,,)"
$ python --version
$ Rscript -e 'system("python --version")'
To permanently change your PATH, edit the file $HOME/.bashrc appropriately. You will need to start a new terminal session for this to have affect.