Search code examples
pythonmatplotlibrpy2arcpy

rpy + matplotlib + arcpy


I am trying to use ryp with my arcpy scripts but I have the following error:

import rpy2.robjects as robjects Traceback (most recent call last):
File "<pyshell#0>", line 1, in <module> import rpy2.robjects as robjects
File "C:\Python26\ArcGIS10.0\lib\site-packages\rpy2\robjects\__init__.py", line 12, in <module> import rpy2.rinterface as rinterface
File "C:\Python26\ArcGIS10.0\lib\site-packages\rpy2\rinterface\__init__.py", line 39, in <module> import win32api
ImportError: No module named win32api

This error comes even after the installation of the pywin32 for my version of python. I've noticed that this seems to be a common error that is usually solved with the installation of pywin32.

I also have a problem with the matplotlib installation, every time i try to use it (import matplotlib.pyplot as plt), python crashes...

Versions:

Python 2.6.6

matplotlib installation: matplotlib-1.1.0.win32-py2.6.exe


Solution

  • You will need to run these scripts with PROPER Python. It seems to me that the ArcPy distribution does not include the win32api module (It also does not exist from example in Python on Mac or Linux).

    I would install PythonXY which includes R bindings, and see if your scripts run there. If they run there, then I (guess) I am correct, and ArcPy does not include these modules.

    A nice BONUS of PythonXY is it's an excellent Python IDE (Spyder), but the real bonus is what the commenter above me said:

    different compiler versions can cause hell of a lot of Problems.

    So, in PythonXY you get a whole bundle compiled with the same compiler.
    Let us know if these made your RPy script run.