2

I have a Mac OS (El Captain) and I'm trying to run R scripts within QGIS 2.14. When I open a script (like one from the online list) I receive the error message:

This algorithm cannot be run :-( This algorithm requires R to be run. Unfortunately, it seems that R is not installed in your system, or it is not correctly configured to be used from QGIS Click here to know more about how to install and configure R to be used with QGIS

Please note that:

  1. R is correctly installed
  2. I followed instructions from http://osgeo-org.1560.x6.nabble.com/R-in-QGIS-on-OSX-using-Kyngchaos-build-td5254567.html
  3. It is not possible to set the R folder, as I did in Windows (see the figure here below), but only the R script folder.

enter image description here

4 Answers 4

2

I just solved the problem following these steps:

  • open the Terminal, digit touch ~/.bash_profile; open ~/.bash_profile and add two rows:

    export R_HOME=“/Library/Frameworks/R.framework/Versions/3.3/Resources” export PYTHONPATH="/Applications/QGIS.app/Contents/Resources/python"

    save the file and close the Terminal

  • open a new Terminal digit sudo nano /etc/paths

    enter your password when prompted

    Go to the bottom of the file, and enter the path you wish to add (in my case was /Library/Frameworks/R.framework/Versions/3.3/Resources).

    Hit control-x to quit.

    Enter “Y” to save the modified buffer.

  • copying the two link files (R and Rscripts) that are in "/usr/local/bin" folder and pasting to "/usr/bin".

  • Restart your MAC

;)

1
  • it did not work
    – osmjit
    Jul 21, 2017 at 19:41
1

OSX 10.13, R 3.4.3, QGIS 2.18.2, GDAL 2.1.2 Python 2.7 I just solved the problem like above:

  1. open the Terminal, type

    nano ~/.bash_profile

  2. add two rows:

    export R_HOME=/Library/Frameworks/R.framework/Versions/3.4/Resources 
    export PYTHONPATH=/Applications/QGIS.app/Contents/Resources/python
    
  3. save the file and close the Terminal

  4. open a new Terminal digit

    sudo nano /etc/paths

    enter your password when prompted Go to the bottom of the file, and enter

    /Library/Frameworks/R.framework/Versions/3.4/Resources

    Hit control-x to quit. Enter “Y” to save the modified buffer.

  5. copying the two link files (R and Rscript) that are in "/usr/local/bin" folder and pasting to "/usr/bin". Pay attention to the version of the R.Framework. Open a terminal window and type

    sudo cp /usr/local/bin/R /Library/Frameworks/R.framework/Versions/3.4/Resources/bin

    cp /usr/local/bin/Rscript /Library/Frameworks/R.framework/Versions/3.4/Resources/bin

  6. Restart OSX

1

Either one of these solutions posted above work, but there is a critical missing bit of information. You need to disable the System Integrity Protection feature in El Capitan as per this link. Once you disable the SIP, you can copy the R and Rscript link files from "/usr/local/bin" folder to "/usr/bin". It worked for me after about 24 hours of frustration and now I can run R scripts in QGIS.

0

Mac Os X is an Unix system and the processing Python module search for an R executable because it uses the subprocess module to execute the script directly with R.

The Python script involved is /Applications/QGIS.app/Contents/Resources/python/plugins/processing/algs/r/RUtils.py

1) it search for the R executable
2) it creates a R script with the command that should be executed (/.../.qgis2/processing/processing_script.r)
3) it executes R processing_script.r with the subprocess module

Therefore, if you can launch R from the terminal (Terminal.app), no problem, you have nothing to do.

enter image description here

If not, try in the Terminal.app

which R 
  • In Yosemite the result is /usr/bin/R with an R executable witch is a symbolic link of /Library/Frameworks/R.framework/Versions/3.x/Resources/bin/R
  • In El Capitan the result is /usr/local/bin/R because of the System Integrity Protection (SIP), About System Integrity Protection on your Mac (you cannot use /usr/bin/, amongst other things, only Apple is allowed to install software under /usr/bin . /usr/local/bin is for the others)

Look at [Qgis-user] R in QGIS on OSX using Kyngchaos build

Simply add PATH="/usr/local/bin:/usr/bin:$PATH" in your .bash_profile file (search in /usr/local/bin/ before /usr/bin/)

1
  • It did not solve the issue
    – osmjit
    Jul 20, 2017 at 13:51

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.