[GRASS-dev] Fwd: [GRASS-user] How to embed a grass script (for
example v.db.addcol) into a Pythonscript on windows?
Michael Barton
Michael.Barton at asu.edu
Thu Apr 1 17:22:50 EDT 2010
OK. This helps. We were trying it in the "MSys' (broken and deprecated) rxvt program".
Like I said, I'm not familiar enough with Windows to realize that this would not work. I'm trying to help get python GRASS scripts to work under Windows. So testing it from MSys is not the way to go. Should we just try running a python script from the wxpython command prompt? Or should we do it from the MSys prompt?
Is there a shebang that we should be using on Windows that is different from the stock one (#!/usr/bin/env python).
I'm looking for a cookbook approach that I can tell to students and other who would like to use GRASS on Windows. I understand that there are difficulties with this, but am trying to find way to make scripting useable for people who cannot compile on Windows, but can modify batch and other scripts. So far, we've
1) installed Python from the python site
2) installed the GRASS binary (not the OSGeo4Win version, but the standalone native Windows one)
3) replaced the startup batch file with the commands you provided
Do we need to do something else? Do we need to start a script in a special way (e.g., by exec-ing python first? Do we need batch files to launch python scripts like we do for bash scripts?
It will be helpful to many to get this worked out, even in a hacked way at the moment.
In a related question, maybe more for Colin, does GRASS 7 work in Windows? If so, what is the setup to allow it to run the scripts in Python?
Thanks
Michael
______________________________
C. Michael Barton
Director, Center for Social Dynamics & Complexity
Professor of Anthropology, School of Human Evolution & Social Change
Arizona State University
Tempe, AZ 85287-2402
USA
voice: 480-965-6262 (SHESC), 480-727-9746 (CSDC)
fax: 480-965-7671(SHESC), 480-727-0709 (CSDC)
www: http://csdc.asu.edu, http://shesc.asu.edu
http://www.public.asu.edu/~cmbarton
On Apr 1, 2010, at 1:54 PM, Glynn Clements wrote:
>
> Michael Barton wrote:
>
>> We've tried the things below and are not getting anywhere. I don't know
>> if we simply don't understand something (I'm not a Windows person, but
>> the 2 students copied are) or there is something more we need to do.
>>
>> So far, we've installed Python from python.org. We've installed it where
>> it normally goes (at the C:\ root) and tried it in Programs.
>>
>> We've substituted your batch file below for the one that comes with
>> GRASS 6.4 svn for Windows.
>>
>> After doing this and trying to run python at the MSys GRASS prompt, it
>> simply comes back to a blank line, as if waiting for something. No
>> Python shell. Is this the wrong way to test this?
>
> By "MSys GRASS prompt", are you talking about running MSys' /bin/sh in
> a Windows console, or in MSys' (broken and deprecated) rxvt program?
>
> Note that Windows versions of Python won't exhibit "interactive"
> behaviour (prompt, input editing) within rxvt, because it isn't a tty
> according to MSVCRT's isatty() function.
>
> If you're using rxvt, you're on your own. Even using /bin/sh may be an
> issue due to the conversions between Windows and MSys filename
> formats.
>
> The batch file which I posted results in a GRASS session using cmd.exe
> within a Windows console.
>
>> If GRASS Python is working for you, we must be close. But I simply don't
>> know how to proceed. Any advice would be welcome.
>
> I can only tell you what works for me, namely using native Windows
> versions in preference to MSys, using GnuWin32 libraries in preference
> to MSys, not using anything from OSGeo4W (except possibly GDAL), not
> using the Windows "packaging" in the GRASS source tree, etc. Just
> configure, make, make install, then a batch file to set a few
> essential environment variables before starting grass65.bat.
>
> --
> Glynn Clements <glynn at gclements.plus.com>
More information about the grass-dev
mailing list