[GRASS-dev] Re: [GRASS-windows] compiling WINGrass Python Scripts - ExpatError

Johannes Radinger JRadinger at gmx.at
Wed Dec 7 03:42:50 EST 2011


Hi,

I tried to run the script now manually with --help
from the command line. For simplicicity I only tried
v.krige.py, a python script that already comes with
the GRASS 6.5 SVN install.

I tried to differnent types but both with problems:

1) with the .py ending:
'''''''''''''''''''''''''''''''''''''''
v.krige.py --help
c:/OSGeo4W/apps/grass/grass-6.5.svn/scripts/v.krige.py:
MODULE:    v.krige
AUTHOR(S): Anne Ghisla <a.ghisla AT gmail.com>
PURPOSE:   Performs ordinary or block kriging
DEPENDS:   R 2.x, packages gstat, maptools and spgrass6,
optional: automap
COPYRIGHT: (C) 2009 by the GRASS Development Team
This program is free software under the GNU General Public
License (>=v2). Read the file COPYING that comes with GRASS
for details.
: command not found
c:/OSGeo4W/apps/grass/grass-6.5.svn/scripts/v.krige.py:
import: command not found
c:/OSGeo4W/apps/grass/grass-6.5.svn/scripts/v.krige.py:
from: command not found
c:/OSGeo4W/apps/grass/grass-6.5.svn/scripts/v.krige.py:
import: command not found
c:/OSGeo4W/apps/grass/grass-6.5.svn/scripts/v.krige.py:
import: command not found
c:/OSGeo4W/apps/grass/grass-6.5.svn/scripts/v.krige.py: line
107: syntax error near unexpected token
`os.environ.has_key("'
c:/OSGeo4W/apps/grass/grass-6.5.svn/scripts/v.krige.py: line
107: `if not os.environ.has_key("GISBASE"):'
(Wed Dec 07 09:29:24 2011) Command finished (0 sec)
Traceback (most recent call last):
   File "c:\OSGeo4W\apps\grass\grass-6.5.svn\etc\wxpython\gui
_modules\goutput.py", line 810, in OnCmdDone

task = menuform.GUI(show = None).ParseCommand(event.cmd)
   File "c:\OSGeo4W\apps\grass\grass-6.5.svn\etc\wxpython\gui
_modules\menuform.py", line 1819, in ParseCommand

blackList = _blackList)
   File "c:/osgeo4w/usr/src/grass-6.5.svn/dist.i686-pc-
mingw32/etc/python/grass/script/task.py", line 457, in
parse_interface
   File
"c:\OSGeo4W\apps\Python25\lib\xml\etree\ElementTree.py",
line 964, in XML

return parser.close()
   File
"c:\OSGeo4W\apps\Python25\lib\xml\etree\ElementTree.py",
line 1254, in close

self._parser.Parse("", 1) # end of data
xml.parsers.expat
.
ExpatError
:
no element found: line 1, column 0
'''''''''''''''''''''''''''''''''''''''


and 2) without the .py ending
'''''''''''''''''''''''''''''''''''''''
v.krige --help
No GRASS-python library found
'''''''''''''''''''''''''''''''''''''''

I also tried to run my own script without the .py ending and with --help:
'''''''''''''''''''''''''''''''''''''''
pythontest_l --help
Traceback (most recent call last):
   File "C:\OSGeo4W\apps\grass\grass-6.5.svn\scripts\pythonte
st_l.py", line 42, in <module>
     import grass.script as grass
ImportError: No module named grass.script
'''''''''''''''''''''''''''''''''''''''


What is the normal way to run a python script in windows, with or 
without the .py ending?

The main python on my Windows 7 and in the environemental variabels 
(Path) is C:\Python27
I need to run the script using my Windows python as there are some 
addtionaly python
modules my script depends on...


Thank you,

/Johannes

Am 05.12.2011 17:52, schrieb Glynn Clements:
> Johannes Radinger wrote:
>
>> self._parser.Parse("", 1) # end of data
>> xml.parsers.expat
>> .
>> ExpatError
>> :
>> no element found: line 1, column 0
>> ''''''''''''''''''''''''''''
>>
>> I don't know what that exactly means?? I tried to compile the script
>> with two different line endings (UNIX coding and Windows coding) but
>> with similar result. So I don't know what is causing the problem!!
> It means that it tried to generate a wxPython GUI for the options, the
> code which generates the GUI executed the command with the
> --interface-description flag to get a list of the options in XML
> format, then passed the output to the Expat XML parser. Unfortunately,
> the command failed to execute, so no XML was generated, and Expat
> complains about not receiving valid XML.
>
> IOW, the error message is accurate but quite useless. To get useful
> information, you'll need to run the script manually from the command
> line. Try running it with the --help option initially.
>



More information about the grass-dev mailing list