[GRASS-user] Grass 6.4 & python.

Milton Cezar Ribeiro miltinho.astronauta at gmail.com
Wed Apr 29 09:02:19 EDT 2009


oops I typed "grass -mx" on email instead of "grass -wx". Sorry.



2009/4/29 Milton Cezar Ribeiro <miltinho.astronauta at gmail.com>

> Hi Glym,
>
> Thanks for the reply. I have tryed on two ways, both not work for me (under
> windows vista).
> 1) start msys; start grass without -mx ; and try to start python from
> inside grass sesssion. The python keep stoped (no error message, but stay
> with only "python" words on the console)
>
> 2) start msys; try to start grass -mx
> here I get the following error:
> GRASS 6.4.0RC4 > grass65 -wx
> Cleaning up temporary files ...
> Starting GRASS ...
> 'import site' failed; use -v for traceback
> Traceback (most recent call last):
>   File "c:/OSGeo4W/apps/grass/grass-6.5.svn/etc/wxpython/gis_set.py", line
> 23, in <module>
>     import os
> ImportError: No module named os
> Error in GUI startup. If necessary, please
> report this error to the GRASS developers.
> Switching to text mode now.
> Hit RETURN to continue..
>
> Any help are welcome.
>
> Bests
>
> milton
>
>
> 2009/4/29 Glynn Clements <glynn at gclements.plus.com>
>
>
>> Milton Cezar Ribeiro wrote:
>>
>> > I started grass under Msys and with the flag -wx.
>> > My difficult now I how can I get starting, with a simple example, like
>> > these on the grass-python page:
>>
>> > My question is how can I make python find the "grass" to run the import.
>> > I need to start python inside a MSYS -> GRASS session, like R do?
>>
>> In order to find grass.py, PYTHONPATH needs to include
>> $GISBASE/etc/python. This is done automatically when you start GRASS.
>>
>> However, the functions in grass.py run GRASS commands, and so require
>> the usual GRASS environment (GISBASE, GISRC, etc). So you need to
>> either run the Python script from within a GRASS session, or set up
>> the GRASS environment by some other means.
>>
>> If you want to write a stand-alone program, you could always have the
>> Python script set up the GRASS environment, e.g. from registry keys
>> (or if this is for your own use, just hard-code everything). You can
>> add directories to the path used for importing Python modules by
>> modifying sys.path, e.g.:
>>
>>        import sys
>>        ...
>>        gisbase = os.normpath(os.environ['GISBASE'])
>>        pydir = os.path.join(gisbase, "etc", "python")
>>        sys.path.append(pydir)
>>
>> You still need to figure out how to determine the database, location,
>> and mapset, though.
>>
>> --
>> Glynn Clements <glynn at gclements.plus.com>
>>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.osgeo.org/pipermail/grass-user/attachments/20090429/82a42258/attachment.html


More information about the grass-user mailing list