Many thanks Carson,
I added the line to in __init__.py and manageRDialog.py (below), if I added to just the manageRDialog.py I got the same can't find R error. I have now just added to __init__.py and get the python error (see below for full): "ImportError: No module named win32api" ...

Any suggestions?

One of the reasons I work with the Renviron.site file is that I switch between R on a USB and R on laptops / desktops. This flexibility is very useful for me and also means I don't require administrator access on computers where I don't have such permission. Would it be possible to have a file selector dialogue so a user can simply "click" the path when manageR / Rpy can't find R? Or maybe a dialogue that says this is the location of R that manageR will use, OK? If not select the location.....

All the best, and many thanks for the great plugins.........
Darren

****File Specifications******
__init__.py:

import ConfigParser
import os.path
os.environ['R_HOME'] = "C:\Users\Darren\R\R-2.9.0\bin"
p = ConfigParser.ConfigParser()
here = os.path.join(os.path.dirname(__file__),"config.ini")
p.read(here)

manageRDialog.py:

import ConfigParser
import os.path
os.environ['R_HOME'] = "C:\Users\Darren\R\R-2.9.0\bin"
parser = ConfigParser.ConfigParser()
here = os.path.join( os.path.dirname( __file__ ),"config.ini" )
parser.read( here )

******************* Python error ********************************************************
An error has occured while executing Python code:

Traceback (most recent call last):
File "C:/Users/Darren/.qgis//python/plugins\manageR\manageR.py", line 49, in run
   import manageRDialog
File "C:/Users/Darren/.qgis//python/plugins\manageR\manageRDialog.py", line 26, in
   from QLayerConverter import QVectorLayerConverter, QRasterLayerConverter
File "C:/Users/Darren/.qgis//python/plugins\manageR\QLayerConverter.py", line 24, in
   import rpy2.robjects as robjects
File "C:/Program Files/Quantum GIS/./python\rpy2\robjects\__init__.py", line 12, in
   import rpy2.rinterface as rinterface
File "C:/Program Files/Quantum GIS/./python\rpy2\rinterface\__init__.py", line 39, in
   import win32api
ImportError: No module named win32api

Python version:
2.5.2 (r252:60911, Feb 21 2008, 13:11:45) [MSC v.1310 32 bit (Intel)]

Python path:['C:/Program Files/Quantum GIS/./python', 'C:/Users/Darren/.qgis//python/plugins', 'C:/Program Files/Quantum GIS/./python/plugins', 'C:\\Program Files\\Quantum GIS\\bin\\python25.zip', '.\\DLLs', '.\\lib', '.\\lib\\plat-win', '.\\lib\\lib-tk', 'C:\\Program Files\\Quantum GIS\\bin', 'C:\\Program Files\\Quantum GIS\\python\\plugins\\fTools\\tools']
Carson Farmer wrote:
Hi Darren,
Just installed manageR (0.6.10) on Windows Vista.
Qgis 1.0.2-Kore installed via standalone installer, R version is 2.9.
ManageR installed via the python plugin installer, following Carson's guide at: http://www.ftools.ca/install.html

Got a python error (below) and it looks like manageR can't find R.
This is not too surprising as I set HOME, R_USER etc via a Renviron.site file.
So R is not in the registry and no environment variables are set.

How do I show manageR where the R.exe file is??
In this case you'll have to set an environment variable I think.

The error that you posted comes up when the following fails:

try:
    R_HOME = os.environ["R_HOME"]
except KeyError:
    R_HOME = os.popen("R RHOME").readlines()
if len(R_HOME) == 0:
    if sys.platform == 'win32':
        try:
            import win32api
            import win32con
            hkey = win32api.RegOpenKeyEx(win32con.HKEY_LOCAL_MACHINE,
                                         "Software\\R-core\\R",
                                         0, win32con.KEY_QUERY_VALUE )
            R_HOME = win32api.RegQueryValueEx(hkey, "InstallPath")[0]
            win32api.RegCloseKey( hkey )
        except:
            raise RuntimeError(
                "Unable to determine R version from the registery." +\
"Calling the command 'R RHOME' does not return anything.\n" +\ "This might be because R.exe is nowhere in your Path.")


So obviously if R isn't in the registry, and there is no R_HOME environment variable, Rpy (which is what manageR uses to talk to R) won't be able to find R. Essentially, you just need to specify the R_HOME environment variable as your R install path.

The other option is to add something like:

import os
os.environ['R_HOME'] = "R/install/path"

to line 20 of either __init__.py or manageRDialog.py in the manageR plugin directory.

Hope that helps,

Carson


_______________________________________________
Qgis-user mailing list
[email protected]
http://lists.osgeo.org/mailman/listinfo/qgis-user

Reply via email to