[GRASS-user] Running Python scripts inside GRASS

Sonja Jankowfsky sonja.jankowfsky at cemagref.fr
Thu Mar 4 05:06:31 EST 2010


I'm inside a GRASS session, with my Windows GRASS Command Line and I try 
to run a python script using GRASS functions:


import os
import grass.script as grass
env = grass.gisenv()
print env
r = grass.read_command("g.list", type='vect')
print r


GRASS 6.4.0svn (YzeronEPSG)> E:\pythoninput\test_simple.py

Output:

Traceback (most recent call last):
  File "E:\pythoninput\test_simple.py", line 2, in <module>
    import grass.script as grass
  File "C:\GRASS-4-SVN\etc\python\grass\script\__init__.py", line 1, in 
<module>

    from core   import *
  File "C:\GRASS-4-SVN\etc\python\grass\script\core.py", line 30, in 
<module>
    import subprocess
  File "C:\GRASS-4-SVN\Python25\lib\subprocess.py", line 376, in <module>
    import threading
  File "C:\GRASS-4-SVN\Python25\lib\threading.py", line 13, in <module>
    from collections import deque
ImportError: No module named collections


Is this an error in the PYTHONPATH? And where can I define it inside GRASS?

Thanks for any help,

Sonja



More information about the grass-user mailing list