[GRASS-user] Running Python scripts inside GRASS

Glynn Clements glynn at gclements.plus.com
Thu Mar 4 16:33:32 EST 2010

Sonja Jankowfsky wrote:

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

>   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?

This indicates either a broken Python installation or broken
configuration. The collections module should be present in 2.5 (it was
added in 2.4).

>From your previous message, I note:


This is wrong. PYTHONPATH should be set to:


It shouldn't contain any other directories. Python can find modules
which are part of the Python distribution without any configuration;
PYTHONPATH is only needed for the Python modules which are part of

Glynn Clements <glynn at gclements.plus.com>

More information about the grass-user mailing list