[GRASS-user] Error when running a scrip in Windows-WinGRASS

M.Onur Kurum mokurum at ncsu.edu
Wed Oct 13 14:28:29 EDT 2010


  I've been a reader in the Grass-users list so far but I wanted to 
follow up with this:

I was trying to get a py script running under Grass 6.4 and 7.0
OS: WIndows 7 64 bit

Here are the results of my experiments, I will try to provide as much 
detail as I can:

I am using http://svn.osgeo.org/grass/grass-addons/raster/r.ipso/ for my 
tests:

GRASS64
I have GRASS 64 installed in C:\GRASS-64
I put the the r.ipso.py in C:\GRASS-64\scripts
I launch the GRASS 6.4.0 with MSYS

when I directly try to launch the module, I get this:

*GRASS 6.4> r.ipso.py
Traceback (most recent call last):
   File "c:/GRASS-64/scripts/r.ipso.py", line 53, in <module>
     import matplotlib.pyplot as plt
   File "C:\GRASS-64\Python25\lib\site-packages\matplotlib\pyplot.py", 
line 78, in <module>
     new_figure_manager, draw_if_interactive, show = pylab_setup()
   File 
"C:\GRASS-64\Python25\lib\site-packages\matplotlib\backends\__init__.py", line 
25, in pylab_setup
     globals(),locals(),[backend_name])
   File 
"C:\GRASS-64\Python25\lib\site-packages\matplotlib\backends\backend_tkagg.py", 
line 7, in <module>
     import Tkinter as Tk, FileDialog
ImportError: No module named Tkinter*

I could workaround this problem by using the Python 26 installed 
separately in C:\Python26 (which has numpy, matplotlib, 
wx-2.8-msw-unicode (wxpython) etc)
apparently python26 interpreter can run the matplotlib better(?).
so I did:

*GRASS 6.4> export 
PATH="/C/GRASS-64/lib:/C/GRASS-64/bin:/C/GRASS-64/scripts:/C/GRASS-64/tcl-tk/bin:/C/GRASS-64/sqlite/bin:/C/GRASS-64/gpsbabel:/C/GRASS-64/extralib:/bin:/C/Python26"
GRASS 6.4> export PYTHONHOME="/C/Python26"
*
note that I removed the C/Grass-64/extrabin to prevent the python.exe 
there to interfere with my python.exe (the one in C:\Python26\) to 
execute - If I don't remove C/Grass-64/extrabin from the PATH, here is 
the result:

*GRASS 6.4> r.ipso.py
c:/Python26\lib\site.py:150: Warning: 'with' will become a reserved 
keyword in Python 2.6
'import site' failed; use -v for traceback
Traceback (most recent call last):
   File "c:/GRASS-70-SVN/scripts/r.ipso.py", line 52, in <module>
     import os
   File "c:/Python26\lib\os.py", line 758
     bs = b""
            ^
SyntaxError: invalid syntax*

so anyway, I change the path as I mentioned above and the result is:

*GRASS 6.4> r.ipso.py
ERROR: Required parameter <map> not set:
     (Name of raster map).
ERROR: Required parameter <image> not set:
     (output graph).
Description:
Keywords:
  raster
Usage:
  r.ipso.py [-ab] map=name image=image [--verbose] [--quiet]

Flags:
   -a   generate ipsometric curve
   -b   generate ipsographic curve
  --v   Verbose module output
  --q   Quiet module output

Parameters:
     map   Name of raster map
   image   output graph
GRASS 6.4> *

so it works, I tried it with  an input map and everything. It creates 
the plot image and everything but the GUI does not launch (in linux it 
does - everything works better there :) ). I want the GUI so that when I 
create my own script I can check how the GUI looks etc.

I tried the same thing GRASS 7 too since it is all Python (which I love ! )

I get a different error when I go r.ipso.py just after launching GRASS 
7.0.SVN with MSYS (Grass7.0 is installed in C:\GRASS-70-SVN - I mention 
this to let you know that I don't go with the default C:\Program Files 
(X86)\GRASS..... which has spaces in it and it creates all kinds of 
problems - I see that it is been fixed, but I still feel this is safer)

*GRASS 7.0.svn> r.ipso.py
Traceback (most recent call last):
   File "c:/GRASS-70-SVN/scripts/r.ipso.py", line 53, in <module>
     import matplotlib.pyplot as plt
ImportError: No module named matplotlib.pyplot*

the reason (probably), C:\GRASS-70-SVN\Python25\Lib\site-packages does 
not come with matplotlib - anyway I trick it again to look for libraries 
under my Python26 by exporting:

*export 
PATH="/C/GRASS-70-SVN/lib:/C/GRASS-70-SVN/bin:/C/GRASS-70-SVN/scripts:/C/GRASS-70-SVN/tcl-tk/bin:/C/GRASS-70-SVN/sqlite/bin:/c/GRASS-70-SVN/gpsbabel:/c/GRASS-70-SVN/extralib:/bin:/c/Python26"
export PYTHONHOME="/C/Python26"*

again note that I don't have the extrabin folder in the PATH

*GRASS 7.0.svn> r.ipso.py
ERROR: wxGUI requires wxPython. No module named wxversion
GRASS 7.0.svn>
*
This is where I am at right now - it seems that it is going to work out 
if I figure out this last "ERROR: wxGUI requires wxPython. No module 
named wxversion" problem in Grass-70.

Any ideas, suggestions ?
I just want to be able to launch the GUI when I have a .py of my own 
under /scripts in grass6.4 or 7.0

thanks
Onur






On 10/4/2010 2:41 PM, Helena Herrera wrote:
> Greetings to all
> I want to know if anyone has ever tried to build Python Scripts on 
> winGRASS 6.x???
> Because I didn't find any literature or document that this was a 
> limition on Windows...
>
>
> On Fri, Oct 1, 2010 at 6:40 PM, Glynn Clements 
> <glynn at gclements.plus.com <mailto:glynn at gclements.plus.com>> wrote:
>
>
>     Helena Herrera wrote:
>
>     > I have developed a Script to import Landsat images that runs
>     just fine in
>     > Linux
>     >
>     > But when I compile (Msys)  with this expressioN:
>     > make -C r.in.landsat
>     >
>     MODULE_TOPDIR=/C/OSGeo4W/usr/src/grass-6.4.svn_src_snapshot_2010_09_04
>     >
>     > and run in GRASS I get this error:
>
>     >
>     xml.sax.parseString(getInterfaceDescription(cmd[0]).decode(enc).split('\n',1)[1].replace('',
>     > '<?xml version="1.0" encoding="utf-8"?>\n', 1).encode("utf-8"),
>
>     > IndexError: list index out of range
>     > 1- Is my compilation expression correct?
>     >
>     > 2- What am I missing on this?
>
>     I'm not sure that Python scripts work in 6.x on Windows. I'm fairly
>     sure that the build system *doesn't* handle Python scripts in 6.x on
>     Windows.
>
>     The main issue is that, on Windows, the build system installs a batch
>     file which executes the actual script, and the batch file only works
>     for shell scripts.
>
>     --
>     Glynn Clements <glynn at gclements.plus.com
>     <mailto:glynn at gclements.plus.com>>
>
>
>
> _______________________________________________
> grass-user mailing list
> grass-user at lists.osgeo.org
> http://lists.osgeo.org/mailman/listinfo/grass-user

-- 

M.Onur Kurum
Graduate Research Assistant
Dept. of Civil, Construction, and Environmental Engineering
North Carolina State University
Campus Box 7908
2501 Stinson Drive, 428 Mann Hall
Raleigh, NC  27695-7908
Office: (919) 515-1340
Mobile: (919) 200-0665
Email: mokurum at ncsu.edu
Email: m.onur.kurum at gmail.com



On 10/4/2010 2:41 PM, Helena Herrera wrote:
> Greetings to all
> I want to know if anyone has ever tried to build Python Scripts on 
> winGRASS 6.x???
> Because I didn't find any literature or document that this was a 
> limition on Windows...
>
>
> On Fri, Oct 1, 2010 at 6:40 PM, Glynn Clements 
> <glynn at gclements.plus.com <mailto:glynn at gclements.plus.com>> wrote:
>
>
>     Helena Herrera wrote:
>
>     > I have developed a Script to import Landsat images that runs
>     just fine in
>     > Linux
>     >
>     > But when I compile (Msys)  with this expressioN:
>     > make -C r.in.landsat
>     >
>     MODULE_TOPDIR=/C/OSGeo4W/usr/src/grass-6.4.svn_src_snapshot_2010_09_04
>     >
>     > and run in GRASS I get this error:
>
>     >
>     xml.sax.parseString(getInterfaceDescription(cmd[0]).decode(enc).split('\n',1)[1].replace('',
>     > '<?xml version="1.0" encoding="utf-8"?>\n', 1).encode("utf-8"),
>
>     > IndexError: list index out of range
>     > 1- Is my compilation expression correct?
>     >
>     > 2- What am I missing on this?
>
>     I'm not sure that Python scripts work in 6.x on Windows. I'm fairly
>     sure that the build system *doesn't* handle Python scripts in 6.x on
>     Windows.
>
>     The main issue is that, on Windows, the build system installs a batch
>     file which executes the actual script, and the batch file only works
>     for shell scripts.
>
>     --
>     Glynn Clements <glynn at gclements.plus.com
>     <mailto:glynn at gclements.plus.com>>
>
>
>
> _______________________________________________
> grass-user mailing list
> grass-user at lists.osgeo.org
> http://lists.osgeo.org/mailman/listinfo/grass-user

-- 

M.Onur Kurum
Graduate Research Assistant
Dept. of Civil, Construction, and Environmental Engineering
North Carolina State University
Campus Box 7908
2501 Stinson Drive, 428 Mann Hall
Raleigh, NC  27695-7908
Office: (919) 515-1340
Mobile: (919) 200-0665
Email: mokurum at ncsu.edu
Email: m.onur.kurum at gmail.com

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.osgeo.org/pipermail/grass-user/attachments/20101013/249e65a8/attachment.html


More information about the grass-user mailing list