I´m trying to write a Python script, that includes different ArcPy / ArcGIS commands and want to combine it with GRASS geoprocessing tools.

Unfortunately importing the GRASS libraries doesn´t work.

import grass.script as grass

ends in an error:

Traceback (most recent call last):
  File "<interactive input>", line 1, in <module>
ImportError: No module named script

I know that GRASS GIS installs it's own Python version. Isn´t there a way to combine the ArcGIS and the GRASS GIS installation of Python? I tried copying the pygrass module (or what I thought it might be it) to the C:\Python26\ArcGIS10.0\Lib\site-packages\ folder. I´m getting a different error message, but it´s still not working.

Traceback (most recent call last):
  File "<interactive input>", line 1, in <module>
  File "C:\Python26\ArcGIS10.0\lib\site-packages\grass\script\__init__.py", line 1, in <module>
    from core   import *
  File "C:\Python26\ArcGIS10.0\lib\site-packages\grass\script\core.py", line 38, in <module>
    gettext.install('grasslibs', os.path.join(os.getenv("GISBASE"), 'locale'))
  File "C:\Python26\ArcGIS10.0\lib\ntpath.py", line 96, in join
    assert len(path) > 0
TypeError: object of type 'NoneType' has no len()

I´m using ArcGIS 10 and GRASS 6.4.2 on a Windows 7 64 Bit machine.

1 Answer 1


Most likely the grass version of Python has installed its own Python bindings into a grass specific site-packages. One non-ideal option would be to add the following prior to importing grass.script:

import sys

What this is doing is temporarily adding grass to your $PYTHONPATH so that your ArcGIS10.0 Python installation finds it when searching for imports.

  • Hey Jay, thanks for your tip. I think the respective folder is .../etc/python/grass/script/. Do I have to reference a specific .py file or all of them?
    – Martin
    Commented Jan 14, 2013 at 14:25
  • 1
    Yes, for example, if I wanted to add the gdal bindings from another folder I would need to use python_install/site-packages/osgeo/gdal.py. Does a grass.py script exist in the grass directory?
    – Jay Laura
    Commented Jan 14, 2013 at 14:39
  • There are several .py files, unfortunately none with a clear name like grass.py . I have tried to reference all of them. Unfortunately it still doesn´t work. :-(
    – Martin
    Commented Jan 14, 2013 at 15:08
  • 1
    Hmmm....one more idea for you to try: It looks like you can install GRASS without using the bundled python, as per the linked post. Perhaps try a reinstall and force GRASS to use the Arc python install? lists.osgeo.org/pipermail/grass-user/2012-June/065178.html
    – Jay Laura
    Commented Jan 15, 2013 at 14:28
  • 1
    I you asked about pygrass but maybe this post is on interest anyway. It talks about arcpy bindings for gdal. arcgis.com/home/item.html?id=1eec30bf5fa042a5a2227b094db89441
    – dango
    Commented Jan 29, 2013 at 19:37

Your Answer

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

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