[GRASS-user] Error in pansharp tool: missing grass.script

Vaclav Petras wenzeslaus at gmail.com
Thu Jun 25 19:20:31 PDT 2015

On Thu, Jun 25, 2015 at 5:40 PM, Andrea Peri <aperi2007 at gmail.com> wrote:

> I report the last tests:
> 2015-06-25 15:15 GMT+02:00 Vaclav Petras <wenzeslaus at gmail.com>:
> >
> >
> > /usr/bin/env python -c "import sys; print(sys.path)"
> >
> ~$ /usr/bin/env python -c "import sys; print(sys.path)"
> ['',
> '/usr/local/lib/python2.7/dist-packages/GDAL-2.0.0-py2.7-linux-x86_64.egg',
> '/usr/lib/python2.7', '/usr/lib/python2.7/plat-linux2',
> '/usr/lib/python2.7/lib-tk', '/usr/lib/python2.7/lib-old',
> '/usr/lib/python2.7/lib-dynload',
> '/usr/local/lib/python2.7/dist-packages',
> '/usr/lib/python2.7/dist-packages',
> '/usr/lib/python2.7/dist-packages/PIL',
> '/usr/lib/pymodules/python2.7',
> '/usr/lib/python2.7/dist-packages/wx-2.8-gtk2-unicode']

Well, nothing unusual if this is outside of GRASS.

> I use the panshapen tools outside from grass.

Well, this is different case then! So, Moritz was right. Did I missed this
information somewhere?

> I set all the Grass env vars  and call the grass tools.
> Is this a wrong use ?

Not wrong, just hard to do. You have to set the variables. There is no way
around it and you have to set them right. There is a function and
documentation to help you with that in Python:


If you would like to do Bash or some other language, then you are on your
own but the list of variables is the same. Multiple suggestions how to do
that are here:


GRASS modules run only in the proper environment which is best ensured by
actually running GRASS. This is probably clear to you now but it never
harms to repeat his because the question resurfaces all over again.

I choose this solution because need to write a batch to process
> periodically from a cron .

You have more options available than setting it yourself.

In 6.4 and 7.0 there is GRASS_BATCH_JOB variable which sets a script to be
executed inside GRASS, then you run `grass`. Either the variable will work
for you in the crontab or you have to write one wrapper script to set it to
the actual script and and call `grass`.

In the trunk (upcoming 7.1), there is --exec parameter which I believe
should cover significant amount of cases (not all unfortunately) where
people were setting the variables or used cumbersome GRASS_BATCH_JOB. You
can run `grass` and in command line specify your script or GRASS module to
be executed inside GRASS session. Here are the resources:


> A.
> --
> -----------------
> Andrea Peri
> . . . . . . . . .
> qwerty àèìòù
> -----------------
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/grass-user/attachments/20150625/963e08a4/attachment-0001.html>

More information about the grass-user mailing list