[GRASS-user] Problem with Python Scripts and grass.script (GRASS 6.5SVN) on Mac

Hi Johannes,

Sorry I couldn't get back to you sooner. But it seems like others have told you about the line ending issue. That's a real problem because most people (myself included) will want to start out by copying an example program from the GRASS site.

...and it will utterly fail to run.

Anyway, now that your got it started, it is a debugging issue. Put in some debugging code like...

print 'my program gets this far'

...at different places to see where it is getting stuck. This is tedious but always seems needed.

Michael
____________________
C. Michael Barton
Director, Center for Social Dynamics & Complexity
Professor of Anthropology, School of Human Evolution & Social Change
Arizona State University

voice: 480-965-6262 (SHESC), 480-727-9746 (CSDC)
fax: 480-965-7671 (SHESC), 480-727-0709 (CSDC)
www: http://www.public.asu.edu/~cmbarton, http://csdc.asu.edu

On Mar 29, 2011, at 3:25 AM, <grass-user-request@lists.osgeo.org> wrote:

Date: Tue, 29 Mar 2011 11:11:12 +0200
From: "Johannes Radinger" <JRadinger@gmx.at>
Subject: [GRASS-user] Problem with Python Scripts and grass.script
  (GRASS 6.5SVN) on Mac
To: grass-user@lists.osgeo.org
Message-ID: <20110329091112.282590@gmx.net>
Content-Type: text/plain; charset="utf-8"

Hello Grass users!

I am working with GRASS 6.5 SVN (r45714, last weeks source) and try to run Python Scripts. After I solved the problem with the line endings, GRASS seems to be able to read my scripts (via launch script...). At least the interactive interface pops up correctly (it seems g.parser can read all my options etc.), but after executing it nothing happens and nothing is processed. I tried it with mapcalc but also with r.thin (one input, one output, so very simple).

I don't know what is the problem or how can I check what the problem is...
...what I've tried already and which may cause the problem is that I cannot import grass.script (import grass.script) in the Terminal (pyhton) and/or IDLE... it says: module not found...

Just for your information I run GRASS on a Apple Mac Snow Leopard (10.6.6)
with Python 2.6.6.

/johannes
--
NEU: FreePhone - kostenlos mobil telefonieren und surfen!
Jetzt informieren: http://www.gmx.net/de/go/freephone

Hello Michael,

thank you for your answer and your tip with the debugging code,
but it doesn't matter where I put it, I fail. I that case grass doesn't
open anymore the interactive menu (from g.parser) for that script and I just get the error:

my program gets this far
ERROR: Required parameter <newmap> not set:
        (output)
ERROR: Required parameter <elevation> not set:
        (input 1)
ERROR: Required parameter <geology> not set:
        (input 2)

if I leave the debugging code out, the interactive menu pops up and I can set the parameters, but nothing is afterwards processed.

what am I doing wrong?

/johannes

-------- Original-Nachricht --------

Datum: Tue, 29 Mar 2011 07:40:28 -0700
Von: Michael Barton <Michael.Barton@asu.edu>
An: grass-user grass-user <grass-user@lists.osgeo.org>, Johannes Radinger <JRadinger@gmx.at>
Betreff: [GRASS-user] Problem with Python Scripts and grass.script (GRASS 6.5SVN) on Mac

Hi Johannes,

Sorry I couldn't get back to you sooner. But it seems like others have
told you about the line ending issue. That's a real problem because most
people (myself included) will want to start out by copying an example program
from the GRASS site.

...and it will utterly fail to run.

Anyway, now that your got it started, it is a debugging issue. Put in some
debugging code like...

print 'my program gets this far'

...at different places to see where it is getting stuck. This is tedious
but always seems needed.

Michael
____________________
C. Michael Barton
Director, Center for Social Dynamics & Complexity
Professor of Anthropology, School of Human Evolution & Social Change
Arizona State University

voice: 480-965-6262 (SHESC), 480-727-9746 (CSDC)
fax: 480-965-7671 (SHESC), 480-727-0709 (CSDC)
www: http://www.public.asu.edu/~cmbarton, http://csdc.asu.edu

On Mar 29, 2011, at 3:25 AM, <grass-user-request@lists.osgeo.org> wrote:

> Date: Tue, 29 Mar 2011 11:11:12 +0200
> From: "Johannes Radinger" <JRadinger@gmx.at>
> Subject: [GRASS-user] Problem with Python Scripts and grass.script
> (GRASS 6.5SVN) on Mac
> To: grass-user@lists.osgeo.org
> Message-ID: <20110329091112.282590@gmx.net>
> Content-Type: text/plain; charset="utf-8"
>
> Hello Grass users!
>
> I am working with GRASS 6.5 SVN (r45714, last weeks source) and try to
run Python Scripts. After I solved the problem with the line endings, GRASS
seems to be able to read my scripts (via launch script...). At least the
interactive interface pops up correctly (it seems g.parser can read all my
options etc.), but after executing it nothing happens and nothing is
processed. I tried it with mapcalc but also with r.thin (one input, one output, so
very simple).
>
> I don't know what is the problem or how can I check what the problem
is...
> ...what I've tried already and which may cause the problem is that I
cannot import grass.script (import grass.script) in the Terminal (pyhton)
and/or IDLE... it says: module not found...
>
> Just for your information I run GRASS on a Apple Mac Snow Leopard
(10.6.6)
> with Python 2.6.6.
>
> /johannes
> --
> NEU: FreePhone - kostenlos mobil telefonieren und surfen!
> Jetzt informieren: http://www.gmx.net/de/go/freephone

_______________________________________________
grass-user mailing list
grass-user@lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/grass-user

--
GMX DSL Doppel-Flat ab 19,99 Euro/mtl.! Jetzt mit
gratis Handy-Flat! http://portal.gmx.net/de/go/dsl

The script I am trying is the simpliest form of a script calling just one
function of GRASS (e.g. mapcalc or r.thin),

attached you can find that script which can be applied e.g. on the spearfish
rasterdataset...and in my opinion it is correct and in the correct order
of commands as mentioned in the grass-wiki and with the correct line endings.

/johannes

(attachments)

testscript.py (1.04 KB)

Johannes Radinger wrote:

The script I am trying is the simpliest form of a script calling just one
function of GRASS (e.g. mapcalc or r.thin),

attached you can find that script which can be applied e.g. on the spearfish
rasterdataset...and in my opinion it is correct and in the correct order
of commands as mentioned in the grass-wiki and with the correct line endings.

FWIW, the script works fine on Linux with current 7.0.

--
Glynn Clements <glynn@gclements.plus.com>

Thank you for your answer...

strange that this script isn't working on my mac...
..does it produce an outputmap on linux?

what can be the reason why I don't get an output
on my mac with current 6.5?

/johannes

Am 30.03.2011 um 19:22 schrieb Glynn Clements:

Johannes Radinger wrote:

The script I am trying is the simpliest form of a script calling just one
function of GRASS (e.g. mapcalc or r.thin),

attached you can find that script which can be applied e.g. on the spearfish
rasterdataset...and in my opinion it is correct and in the correct order
of commands as mentioned in the grass-wiki and with the correct line endings.

FWIW, the script works fine on Linux with current 7.0.

--
Glynn Clements <glynn@gclements.plus.com>

Johannes Radinger wrote:

strange that this script isn't working on my mac...
..does it produce an outputmap on linux?

Yes.

what can be the reason why I don't get an output
on my mac with current 6.5?

I don't know.

--
Glynn Clements <glynn@gclements.plus.com>

Hello again,

I tried to figure out the problem with william kyngesburye.
the script is also working on his mac. I saved the script in the bin
folder and ran in the GRASS terminal:

GRASS 6.5.svn (gisdemo_ncspm):~ > testscript.py newmap=test elevation=elevation.10m geology=geology
Traceback (most recent call last):
File "/Library/GRASS/6.5/Modules/bin/testscript.py", line 54, in <module>
   sys.exit(main())
File "/Library/GRASS/6.5/Modules/bin/testscript.py", line 47, in main
   grass.mapcalc("${newmap} = ${elevation} * ${geology}",
AttributeError: 'module' object has no attribute 'mapcalc'

What causes this AttributeError?
Any ideas?

sys.path and $PYTHONPATH seems to be okay according to william.

/johannes

Am 01.04.2011 um 18:04 schrieb Glynn Clements:

Johannes Radinger wrote:

strange that this script isn't working on my mac...
..does it produce an outputmap on linux?

Yes.

what can be the reason why I don't get an output
on my mac with current 6.5?

I don't know.

--
Glynn Clements <glynn@gclements.plus.com>

Have you installed Python from python.org on your Mac? If you have, there may be a problem with that.

Michael
____________________
C. Michael Barton
Director, Center for Social Dynamics & Complexity
Professor of Anthropology, School of Human Evolution & Social Change
Arizona State University

voice: 480-965-6262 (SHESC), 480-727-9746 (CSDC)
fax: 480-965-7671 (SHESC), 480-727-0709 (CSDC)
www: http://www.public.asu.edu/~cmbarton, http://csdc.asu.edu

On Apr 1, 2011, at 9:33 AM, Johannes Radinger wrote:

Hello again,

I tried to figure out the problem with william kyngesburye.
the script is also working on his mac. I saved the script in the bin
folder and ran in the GRASS terminal:

GRASS 6.5.svn (gisdemo_ncspm):~ > testscript.py newmap=test elevation=elevation.10m geology=geology
Traceback (most recent call last):
File "/Library/GRASS/6.5/Modules/bin/testscript.py", line 54, in <module>
  sys.exit(main())
File "/Library/GRASS/6.5/Modules/bin/testscript.py", line 47, in main
  grass.mapcalc("${newmap} = ${elevation} * ${geology}",
AttributeError: 'module' object has no attribute 'mapcalc'

What causes this AttributeError?
Any ideas?

sys.path and $PYTHONPATH seems to be okay according to william.

/johannes

Am 01.04.2011 um 18:04 schrieb Glynn Clements:

Johannes Radinger wrote:

strange that this script isn't working on my mac...
..does it produce an outputmap on linux?

Yes.

what can be the reason why I don't get an output
on my mac with current 6.5?

I don't know.

--
Glynn Clements <glynn@gclements.plus.com>

Johannes Radinger wrote:

I tried to figure out the problem with william kyngesburye.
the script is also working on his mac. I saved the script in the bin
folder and ran in the GRASS terminal:

AttributeError: 'module' object has no attribute 'mapcalc'

What causes this AttributeError?

The grass.script module is either broken or very old (the mapcalc()
function was added in December 2008).

From within GRASS, try the following:

  $ python
  > import grass.script as grass
  > print grass.__file__
  > print grass.__path__

--
Glynn Clements <glynn@gclements.plus.com>

Hello Glynn,
Hello Michael,

the answers to your suggestions/questions below:

Am 02.04.2011 um 17:24 schrieb Michael Barton:

Have you installed Python from python.org on your Mac? If you have, there may be a problem with that.

Yes I there is python2.6.6 from python.org installed but William Kyngesburye told me that this shouldn’t be any
Problem and GRASS GIS can handle this, but I am not sure. Maybe I’ve to try to deinstall it, but I don’t know how excatly so that everything is removed correctly also in the libs.

Michael


C. Michael Barton
Director, Center for Social Dynamics & Complexity
Professor of Anthropology, School of Human Evolution & Social Change
Arizona State University

voice: 480-965-6262 (SHESC), 480-727-9746 (CSDC)
fax: 480-965-7671 (SHESC), 480-727-0709 (CSDC)
www: http://www.public.asu.edu/~cmbarton, http://csdc.asu.ed

Am 03.04.2011 um 00:37 schrieb Glynn Clements:

Johannes Radinger wrote:

I tried to figure out the problem with william kyngesburye.

the script is also working on his mac. I saved the script in the bin

folder and ran in the GRASS terminal:

AttributeError: ‘module’ object has no attribute ‘mapcalc’

What causes this AttributeError?

The grass.script module is either broken or very old (the mapcalc()

The GRASS build I’ve got is compiled from last weeks source (6.5)…

function was added in December 2008).

From within GRASS, try the following:

$ python

import grass.script as grass
print grass.file

that is what I get… does that help you?

/Applications/GRASS-6.5.app/Contents/MacOS/etc/python/grass/script/init.pyc

print grass.path

and for the path:

[‘/Applications/GRASS-6.5.app/Contents/MacOS/etc/python/grass/script’]

/johannes


Glynn Clements <glynn@gclements.plus.com>

When I and others have had a copy of Python from python.org<http://python.org> installed, it has usually caused problems, including bogus errors. I strongly advise against it. In theory, it should not be a problem, but in reality (in my experience) it IS a problem.

I can't say for sure that this is where your problem lies, but I'd be suspicious. When you start python from the terminal, which one is it? How about from GRASS?

Michael
____________________
C. Michael Barton
Director, Center for Social Dynamics & Complexity
Professor of Anthropology, School of Human Evolution & Social Change
Arizona State University

voice: 480-965-6262 (SHESC), 480-727-9746 (CSDC)
fax: 480-965-7671 (SHESC), 480-727-0709 (CSDC)
www: http://www.public.asu.edu/~cmbarton, http://csdc.asu.edu

On Apr 3, 2011, at 12:23 PM, Johannes Radinger wrote:

Hello Glynn,
Hello Michael,

the answers to your suggestions/questions below:

Am 02.04.2011 um 17:24 schrieb Michael Barton:

Have you installed Python from python.org<http://python.org/&gt; on your Mac? If you have, there may be a problem with that.

Yes I there is python2.6.6 from python.org<http://python.org/&gt; installed but William Kyngesburye told me that this shouldn't be any
Problem and GRASS GIS can handle this, but I am not sure. Maybe I've to try to deinstall it, but I don't know how excatly so that everything is removed correctly also in the libs.

Michael
____________________
C. Michael Barton
Director, Center for Social Dynamics & Complexity
Professor of Anthropology, School of Human Evolution & Social Change
Arizona State University

voice: 480-965-6262 (SHESC), 480-727-9746 (CSDC)
fax: 480-965-7671 (SHESC), 480-727-0709 (CSDC)
www: http://www.public.asu.edu/~cmbarton, http://csdc.asu.edu/&gt;

Am 03.04.2011 um 00:37 schrieb Glynn Clements:

Johannes Radinger wrote:

I tried to figure out the problem with william kyngesburye.
the script is also working on his mac. I saved the script in the bin
folder and ran in the GRASS terminal:

AttributeError: 'module' object has no attribute 'mapcalc'

What causes this AttributeError?

The grass.script module is either broken or very old (the mapcalc()
The GRASS build I've got is compiled from last weeks source (6.5)...

function was added in December 2008).

From within GRASS, try the following:

$ python

import grass.script as grass
print grass.__file__

that is what I get... does that help you?

/Applications/GRASS-6.5.app/Contents/MacOS/etc/python/grass/script/__init__.pyc

print grass.__path__

and for the path:
['/Applications/GRASS-6.5.app/Contents/MacOS/etc/python/grass/script']

/johannes

--
Glynn Clements <glynn@gclements.plus.com<mailto:glynn@gclements.plus.com>>

Hello again,

as recommended I removed the python.org-python (and removed the lines to python.framework in the PATH.
When I now start python it is only the version 2.6.1 (also GRASS now uses this version) which should be the system-python. After removing the other python I recompiled the most recent version of GRASS 6.5, put my mapcalc-testscript into the bin folder and tried to run it both, from launch script and from the GRASS-Terminal. But there is still the same error:

GRASS 6.5.svn (gisdemo_ncspm):~ > testscript.py newmap=test elevation=elevation geology=geology
Traceback (most recent call last):
  File "/Library/GRASS/6.5/Modules/bin/testscript.py", line 54, in <module>
    sys.exit(main())
  File "/Library/GRASS/6.5/Modules/bin/testscript.py", line 47, in main
    grass.mapcalc("${newmap} = ${elevation} * ${geology}",
AttributeError: 'module' object has no attribute 'mapcalc'

Here some addtional info from within the GRASS Terminal:
echo "$PYTHONPATH"
/Applications/GRASS-6.5.app/Contents/MacOS/etc/python

my sys.path (in GRASS-terminal python) is:
['', '/Library/Frameworks/SQLite3.framework/Versions/3/Python', '/Library/Python/2.6/site-packages/numpy-override', '/Library/Frameworks/GDAL.framework/Versions/1.8/Python/site-packages', '/Library/Frameworks/cairo.framework/Versions/1/Python', '/Applications/GRASS-6.5.app/Contents/MacOS/etc/python', '/usr/local/lib/wxPython-unicode-2.8.11.0/lib/python2.6/site-packages', '/usr/local/lib/wxPython-unicode-2.8.11.0/lib/python2.6/site-packages/wx-2.8-mac-unicode', '/System/Library/Frameworks/Python.framework/Versions/2.6/lib/python26.zip', '/System/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6', '/System/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/plat-darwin', '/System/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/plat-mac', '/System/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/plat-mac/lib-scriptpackages', '/System/Library/Frameworks/Python.framework/Versions/2.6/Extras/lib/python', '/System/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/lib-tk', '/System/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/lib-old', '/System/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/lib-dynload', '/Library/Python/2.6/site-packages', '/usr/local/lib/wxPython-unicode-2.8.11.0/lib/python2.6', '/System/Library/Frameworks/Python.framework/Versions/2.6/Extras/lib/python/PyObjC', '/System/Library/Frameworks/Python.framework/Versions/2.6/Extras/lib/python/wx-2.8-mac-unicode']

that is strange because there is no python.framework anymore so where does this come from?

The normal Terminal gives me for $PATH:
/opt/local/bin:/opt/local/sbin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/X11/bin

So maybe the sys.path is a hint for my problem...

/johannes

-------- Original-Nachricht --------

Datum: Sun, 3 Apr 2011 15:27:41 -0700
Von: Michael Barton <Michael.Barton@asu.edu>
An: Johannes Radinger <JRadinger@gmx.at>
CC: "grass-user@lists.osgeo.org" <grass-user@lists.osgeo.org>
Betreff: Re: [GRASS-user] Problem with Python Scripts and grass.script (GRASS 6.5SVN) on Mac

When I and others have had a copy of Python from
python.org<http://python.org> installed, it has usually caused problems, including bogus errors. I
strongly advise against it. In theory, it should not be a problem, but in
reality (in my experience) it IS a problem.

I can't say for sure that this is where your problem lies, but I'd be
suspicious. When you start python from the terminal, which one is it? How about
from GRASS?

Michael
____________________
C. Michael Barton
Director, Center for Social Dynamics & Complexity
Professor of Anthropology, School of Human Evolution & Social Change
Arizona State University

voice: 480-965-6262 (SHESC), 480-727-9746 (CSDC)
fax: 480-965-7671 (SHESC), 480-727-0709 (CSDC)
www: http://www.public.asu.edu/~cmbarton, http://csdc.asu.edu

On Apr 3, 2011, at 12:23 PM, Johannes Radinger wrote:

Hello Glynn,
Hello Michael,

the answers to your suggestions/questions below:

Am 02.04.2011 um 17:24 schrieb Michael Barton:

Have you installed Python from python.org<http://python.org/&gt; on your Mac?
If you have, there may be a problem with that.

Yes I there is python2.6.6 from python.org<http://python.org/&gt; installed
but William Kyngesburye told me that this shouldn't be any
Problem and GRASS GIS can handle this, but I am not sure. Maybe I've to
try to deinstall it, but I don't know how excatly so that everything is
removed correctly also in the libs.

Michael
____________________
C. Michael Barton
Director, Center for Social Dynamics & Complexity
Professor of Anthropology, School of Human Evolution & Social Change
Arizona State University

voice: 480-965-6262 (SHESC), 480-727-9746 (CSDC)
fax: 480-965-7671 (SHESC), 480-727-0709 (CSDC)
www: http://www.public.asu.edu/~cmbarton,
http://csdc.asu.edu/&gt;

Am 03.04.2011 um 00:37 schrieb Glynn Clements:

Johannes Radinger wrote:

I tried to figure out the problem with william kyngesburye.
the script is also working on his mac. I saved the script in the bin
folder and ran in the GRASS terminal:

AttributeError: 'module' object has no attribute 'mapcalc'

What causes this AttributeError?

The grass.script module is either broken or very old (the mapcalc()
The GRASS build I've got is compiled from last weeks source (6.5)...

function was added in December 2008).

>From within GRASS, try the following:

$ python
> import grass.script as grass
> print grass.__file__
that is what I get... does that help you?

/Applications/GRASS-6.5.app/Contents/MacOS/etc/python/grass/script/__init__.pyc

> print grass.__path__
and for the path:
['/Applications/GRASS-6.5.app/Contents/MacOS/etc/python/grass/script']

/johannes

--
Glynn Clements <glynn@gclements.plus.com<mailto:glynn@gclements.plus.com>>

_______________________________________________
grass-user mailing list
grass-user@lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/grass-user

--
NEU: FreePhone - kostenlos mobil telefonieren und surfen!
Jetzt informieren: http://www.gmx.net/de/go/freephone

So some additional information:

I tried now to run another simple script
including the r.thin command (with grass.run_command("r.thin",....)
and thats working perfectly...it seems that it is just a mapcalc
problem, but I still don't understand why its only a problem in my
case and not on your computers.
The normal mapcalculator works fine...its just a pyhton-script problem.

what should I do next?

/johannes

-------- Original-Nachricht --------

Datum: Mon, 04 Apr 2011 11:34:54 +0200
Von: "Johannes Radinger" <JRadinger@gmx.at>
An: Michael Barton <Michael.Barton@asu.edu>
CC: grass-user@lists.osgeo.org
Betreff: Re: [GRASS-user] Problem with Python Scripts and grass.script (GRASS 6.5SVN) on Mac

Hello again,

as recommended I removed the python.org-python (and removed the lines to
python.framework in the PATH.
When I now start python it is only the version 2.6.1 (also GRASS now uses
this version) which should be the system-python. After removing the other
python I recompiled the most recent version of GRASS 6.5, put my
mapcalc-testscript into the bin folder and tried to run it both, from launch script
and from the GRASS-Terminal. But there is still the same error:

GRASS 6.5.svn (gisdemo_ncspm):~ > testscript.py newmap=test
elevation=elevation geology=geology
Traceback (most recent call last):
  File "/Library/GRASS/6.5/Modules/bin/testscript.py", line 54, in
<module>
    sys.exit(main())
  File "/Library/GRASS/6.5/Modules/bin/testscript.py", line 47, in main
    grass.mapcalc("${newmap} = ${elevation} * ${geology}",
AttributeError: 'module' object has no attribute 'mapcalc'

Here some addtional info from within the GRASS Terminal:
echo "$PYTHONPATH"
/Applications/GRASS-6.5.app/Contents/MacOS/etc/python

my sys.path (in GRASS-terminal python) is:
['', '/Library/Frameworks/SQLite3.framework/Versions/3/Python',
'/Library/Python/2.6/site-packages/numpy-override',
'/Library/Frameworks/GDAL.framework/Versions/1.8/Python/site-packages',
'/Library/Frameworks/cairo.framework/Versions/1/Python',
'/Applications/GRASS-6.5.app/Contents/MacOS/etc/python', '/usr/local/lib/wxPython-unicode-2.8.11.0/lib/python2.6/site-packages',
'/usr/local/lib/wxPython-unicode-2.8.11.0/lib/python2.6/site-packages/wx-2.8-mac-unicode',
'/System/Library/Frameworks/Python.framework/Versions/2.6/lib/python26.zip',
'/System/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6',
'/System/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/plat-darwin',
'/System/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/plat-mac',
'/System/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/plat-mac/lib-scriptpackages',
'/System/Library/Frameworks/Python.framework/Versions/2.6/Extras/lib/python',
'/System/Library/Framewor
ks/Python.framework/Versions/2.6/lib/python2.6/lib-tk',
'/System/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/lib-old',
'/System/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/lib-dynload',
'/Library/Python/2.6/site-packages',
'/usr/local/lib/wxPython-unicode-2.8.11.0/lib/python2.6',
'/System/Library/Frameworks/Python.framework/Versions/2.6/Extras/lib/python/PyObjC',
'/System/Library/Frameworks/Python.framework/Versions/2.6/Extras/lib/python/wx-2.8-mac-unicode']

that is strange because there is no python.framework anymore so where does
this come from?

The normal Terminal gives me for $PATH:
/opt/local/bin:/opt/local/sbin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/X11/bin

So maybe the sys.path is a hint for my problem...

/johannes

-------- Original-Nachricht --------
> Datum: Sun, 3 Apr 2011 15:27:41 -0700
> Von: Michael Barton <Michael.Barton@asu.edu>
> An: Johannes Radinger <JRadinger@gmx.at>
> CC: "grass-user@lists.osgeo.org" <grass-user@lists.osgeo.org>
> Betreff: Re: [GRASS-user] Problem with Python Scripts and
grass.script (GRASS 6.5SVN) on Mac

> When I and others have had a copy of Python from
> python.org<http://python.org> installed, it has usually caused problems,
including bogus errors. I
> strongly advise against it. In theory, it should not be a problem, but
in
> reality (in my experience) it IS a problem.
>
> I can't say for sure that this is where your problem lies, but I'd be
> suspicious. When you start python from the terminal, which one is it?
How about
> from GRASS?
>
> Michael
> ____________________
> C. Michael Barton
> Director, Center for Social Dynamics & Complexity
> Professor of Anthropology, School of Human Evolution & Social Change
> Arizona State University
>
> voice: 480-965-6262 (SHESC), 480-727-9746 (CSDC)
> fax: 480-965-7671 (SHESC), 480-727-0709 (CSDC)
> www: http://www.public.asu.edu/~cmbarton, http://csdc.asu.edu
>
>
>
>
>
>
>
>
>
>
>
> On Apr 3, 2011, at 12:23 PM, Johannes Radinger wrote:
>
> Hello Glynn,
> Hello Michael,
>
> the answers to your suggestions/questions below:
>
>
> Am 02.04.2011 um 17:24 schrieb Michael Barton:
>
> Have you installed Python from python.org<http://python.org/&gt; on your
Mac?
> If you have, there may be a problem with that.
>
> Yes I there is python2.6.6 from python.org<http://python.org/&gt; installed
> but William Kyngesburye told me that this shouldn't be any
> Problem and GRASS GIS can handle this, but I am not sure. Maybe I've to
> try to deinstall it, but I don't know how excatly so that everything is
> removed correctly also in the libs.
>
>
>
> Michael
> ____________________
> C. Michael Barton
> Director, Center for Social Dynamics & Complexity
> Professor of Anthropology, School of Human Evolution & Social Change
> Arizona State University
>
> voice: 480-965-6262 (SHESC), 480-727-9746 (CSDC)
> fax: 480-965-7671 (SHESC), 480-727-0709 (CSDC)
> www: http://www.public.asu.edu/~cmbarton,
> http://csdc.asu.edu/&gt;
>
> Am 03.04.2011 um 00:37 schrieb Glynn Clements:
>
> Johannes Radinger wrote:
>
> I tried to figure out the problem with william kyngesburye.
> the script is also working on his mac. I saved the script in the bin
> folder and ran in the GRASS terminal:
>
> AttributeError: 'module' object has no attribute 'mapcalc'
>
>
> What causes this AttributeError?
>
> The grass.script module is either broken or very old (the mapcalc()
> The GRASS build I've got is compiled from last weeks source (6.5)...
>
> function was added in December 2008).
>
> >From within GRASS, try the following:
>
> $ python
> > import grass.script as grass
> > print grass.__file__
> that is what I get... does that help you?
>
>
/Applications/GRASS-6.5.app/Contents/MacOS/etc/python/grass/script/__init__.pyc
>
> > print grass.__path__
> and for the path:
> ['/Applications/GRASS-6.5.app/Contents/MacOS/etc/python/grass/script']
>
>
> /johannes
>
>
>
> --
> Glynn Clements
<glynn@gclements.plus.com<mailto:glynn@gclements.plus.com>>
>
>
> _______________________________________________
> grass-user mailing list
> grass-user@lists.osgeo.org
> http://lists.osgeo.org/mailman/listinfo/grass-user

--
NEU: FreePhone - kostenlos mobil telefonieren und surfen!
Jetzt informieren: http://www.gmx.net/de/go/freephone
_______________________________________________
grass-user mailing list
grass-user@lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/grass-user

--
NEU: FreePhone - kostenlos mobil telefonieren und surfen!
Jetzt informieren: http://www.gmx.net/de/go/freephone

Problem solved!!!!

I figured out what my problem was:
I only loaded the core module instead of all from grass script.
I did that because of some recommondations earlier on but i found in the .py files of grass that the core doesn't inlcude the mapcalc function (is part of the raster-module). So it seems that it is working now.

thank you all (Glynn, William, Michael)!!!

/johannes

-------- Original-Nachricht --------

Datum: Mon, 04 Apr 2011 14:21:22 +0200
Von: "Johannes Radinger" <JRadinger@gmx.at>
An: Michael.Barton@asu.edu
CC: grass-user@lists.osgeo.org
Betreff: Re: [GRASS-user] Problem with Python Scripts and grass.script (GRASS 6.5SVN) on Mac

So some additional information:

I tried now to run another simple script
including the r.thin command (with grass.run_command("r.thin",....)
and thats working perfectly...it seems that it is just a mapcalc
problem, but I still don't understand why its only a problem in my
case and not on your computers.
The normal mapcalculator works fine...its just a pyhton-script problem.

what should I do next?

/johannes

-------- Original-Nachricht --------
> Datum: Mon, 04 Apr 2011 11:34:54 +0200
> Von: "Johannes Radinger" <JRadinger@gmx.at>
> An: Michael Barton <Michael.Barton@asu.edu>
> CC: grass-user@lists.osgeo.org
> Betreff: Re: [GRASS-user] Problem with Python Scripts and
grass.script (GRASS 6.5SVN) on Mac

> Hello again,
>
> as recommended I removed the python.org-python (and removed the lines to
> python.framework in the PATH.
> When I now start python it is only the version 2.6.1 (also GRASS now
uses
> this version) which should be the system-python. After removing the
other
> python I recompiled the most recent version of GRASS 6.5, put my
> mapcalc-testscript into the bin folder and tried to run it both, from
launch script
> and from the GRASS-Terminal. But there is still the same error:
>
> GRASS 6.5.svn (gisdemo_ncspm):~ > testscript.py newmap=test
> elevation=elevation geology=geology
> Traceback (most recent call last):
> File "/Library/GRASS/6.5/Modules/bin/testscript.py", line 54, in
> <module>
> sys.exit(main())
> File "/Library/GRASS/6.5/Modules/bin/testscript.py", line 47, in main
> grass.mapcalc("${newmap} = ${elevation} * ${geology}",
> AttributeError: 'module' object has no attribute 'mapcalc'
>
> Here some addtional info from within the GRASS Terminal:
> echo "$PYTHONPATH"
> /Applications/GRASS-6.5.app/Contents/MacOS/etc/python
>
> my sys.path (in GRASS-terminal python) is:
> ['', '/Library/Frameworks/SQLite3.framework/Versions/3/Python',
> '/Library/Python/2.6/site-packages/numpy-override',
> '/Library/Frameworks/GDAL.framework/Versions/1.8/Python/site-packages',
> '/Library/Frameworks/cairo.framework/Versions/1/Python',
> '/Applications/GRASS-6.5.app/Contents/MacOS/etc/python',
'/usr/local/lib/wxPython-unicode-2.8.11.0/lib/python2.6/site-packages',
>
'/usr/local/lib/wxPython-unicode-2.8.11.0/lib/python2.6/site-packages/wx-2.8-mac-unicode',
>
'/System/Library/Frameworks/Python.framework/Versions/2.6/lib/python26.zip',
>
'/System/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6',
>
'/System/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/plat-darwin',
>
'/System/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/plat-mac',
>
'/System/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/plat-mac/lib-scriptpackages',
>
'/System/Library/Frameworks/Python.framework/Versions/2.6/Extras/lib/python',
> '/System/Library/Framewor
> ks/Python.framework/Versions/2.6/lib/python2.6/lib-tk',
>
'/System/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/lib-old',
>
'/System/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/lib-dynload',
> '/Library/Python/2.6/site-packages',
> '/usr/local/lib/wxPython-unicode-2.8.11.0/lib/python2.6',
>
'/System/Library/Frameworks/Python.framework/Versions/2.6/Extras/lib/python/PyObjC',
>
'/System/Library/Frameworks/Python.framework/Versions/2.6/Extras/lib/python/wx-2.8-mac-unicode']
>
> that is strange because there is no python.framework anymore so where
does
> this come from?
>
> The normal Terminal gives me for $PATH:
>
/opt/local/bin:/opt/local/sbin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/X11/bin
>
> So maybe the sys.path is a hint for my problem...
>
> /johannes
>
>
>
> -------- Original-Nachricht --------
> > Datum: Sun, 3 Apr 2011 15:27:41 -0700
> > Von: Michael Barton <Michael.Barton@asu.edu>
> > An: Johannes Radinger <JRadinger@gmx.at>
> > CC: "grass-user@lists.osgeo.org" <grass-user@lists.osgeo.org>
> > Betreff: Re: [GRASS-user] Problem with Python Scripts and
> grass.script (GRASS 6.5SVN) on Mac
>
> > When I and others have had a copy of Python from
> > python.org<http://python.org> installed, it has usually caused
problems,
> including bogus errors. I
> > strongly advise against it. In theory, it should not be a problem, but
> in
> > reality (in my experience) it IS a problem.
> >
> > I can't say for sure that this is where your problem lies, but I'd be
> > suspicious. When you start python from the terminal, which one is it?
> How about
> > from GRASS?
> >
> > Michael
> > ____________________
> > C. Michael Barton
> > Director, Center for Social Dynamics & Complexity
> > Professor of Anthropology, School of Human Evolution & Social Change
> > Arizona State University
> >
> > voice: 480-965-6262 (SHESC), 480-727-9746 (CSDC)
> > fax: 480-965-7671 (SHESC), 480-727-0709 (CSDC)
> > www: http://www.public.asu.edu/~cmbarton, http://csdc.asu.edu
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> > On Apr 3, 2011, at 12:23 PM, Johannes Radinger wrote:
> >
> > Hello Glynn,
> > Hello Michael,
> >
> > the answers to your suggestions/questions below:
> >
> >
> > Am 02.04.2011 um 17:24 schrieb Michael Barton:
> >
> > Have you installed Python from python.org<http://python.org/&gt; on your
> Mac?
> > If you have, there may be a problem with that.
> >
> > Yes I there is python2.6.6 from python.org<http://python.org/&gt;
installed
> > but William Kyngesburye told me that this shouldn't be any
> > Problem and GRASS GIS can handle this, but I am not sure. Maybe I've
to
> > try to deinstall it, but I don't know how excatly so that everything
is
> > removed correctly also in the libs.
> >
> >
> >
> > Michael
> > ____________________
> > C. Michael Barton
> > Director, Center for Social Dynamics & Complexity
> > Professor of Anthropology, School of Human Evolution & Social Change
> > Arizona State University
> >
> > voice: 480-965-6262 (SHESC), 480-727-9746 (CSDC)
> > fax: 480-965-7671 (SHESC), 480-727-0709 (CSDC)
> > www: http://www.public.asu.edu/~cmbarton,
> > http://csdc.asu.edu/&gt;
> >
> > Am 03.04.2011 um 00:37 schrieb Glynn Clements:
> >
> > Johannes Radinger wrote:
> >
> > I tried to figure out the problem with william kyngesburye.
> > the script is also working on his mac. I saved the script in the bin
> > folder and ran in the GRASS terminal:
> >
> > AttributeError: 'module' object has no attribute 'mapcalc'
> >
> >
> > What causes this AttributeError?
> >
> > The grass.script module is either broken or very old (the mapcalc()
> > The GRASS build I've got is compiled from last weeks source (6.5)...
> >
> > function was added in December 2008).
> >
> > >From within GRASS, try the following:
> >
> > $ python
> > > import grass.script as grass
> > > print grass.__file__
> > that is what I get... does that help you?
> >
> >
>
/Applications/GRASS-6.5.app/Contents/MacOS/etc/python/grass/script/__init__.pyc
> >
> > > print grass.__path__
> > and for the path:
> > ['/Applications/GRASS-6.5.app/Contents/MacOS/etc/python/grass/script']
> >
> >
> > /johannes
> >
> >
> >
> > --
> > Glynn Clements
> <glynn@gclements.plus.com<mailto:glynn@gclements.plus.com>>
> >
> >
> > _______________________________________________
> > grass-user mailing list
> > grass-user@lists.osgeo.org
> > http://lists.osgeo.org/mailman/listinfo/grass-user
>
> --
> NEU: FreePhone - kostenlos mobil telefonieren und surfen!
> Jetzt informieren: http://www.gmx.net/de/go/freephone
> _______________________________________________
> grass-user mailing list
> grass-user@lists.osgeo.org
> http://lists.osgeo.org/mailman/listinfo/grass-user

--
NEU: FreePhone - kostenlos mobil telefonieren und surfen!
Jetzt informieren: http://www.gmx.net/de/go/freephone
_______________________________________________
grass-user mailing list
grass-user@lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/grass-user

--
Ihr GMX Postfach immer dabei: die kostenlose GMX Mail App für Android.
Komfortabel, sicher und schnell: www.gmx.de/android

Great. You may have had a couple of issues: multiple pythons and then trying to fix that by only loading core module. This made it run but without mapcalc

Michael
____________________
C. Michael Barton
Director, Center for Social Dynamics & Complexity
Professor of Anthropology, School of Human Evolution & Social Change
Arizona State University

voice: 480-965-6262 (SHESC), 480-727-9746 (CSDC)
fax: 480-965-7671 (SHESC), 480-727-0709 (CSDC)
www: http://www.public.asu.edu/~cmbarton, http://csdc.asu.edu

On Apr 4, 2011, at 5:40 AM, Johannes Radinger wrote:

Problem solved!!!!

I figured out what my problem was:
I only loaded the core module instead of all from grass script.
I did that because of some recommondations earlier on but i found in the .py files of grass that the core doesn't inlcude the mapcalc function (is part of the raster-module). So it seems that it is working now.

thank you all (Glynn, William, Michael)!!!

/johannes

-------- Original-Nachricht --------

Datum: Mon, 04 Apr 2011 14:21:22 +0200
Von: "Johannes Radinger" <JRadinger@gmx.at>
An: Michael.Barton@asu.edu
CC: grass-user@lists.osgeo.org
Betreff: Re: [GRASS-user] Problem with Python Scripts and grass.script (GRASS 6.5SVN) on Mac

So some additional information:

I tried now to run another simple script
including the r.thin command (with grass.run_command("r.thin",....)
and thats working perfectly...it seems that it is just a mapcalc
problem, but I still don't understand why its only a problem in my
case and not on your computers.
The normal mapcalculator works fine...its just a pyhton-script problem.

what should I do next?

/johannes

-------- Original-Nachricht --------

Datum: Mon, 04 Apr 2011 11:34:54 +0200
Von: "Johannes Radinger" <JRadinger@gmx.at>
An: Michael Barton <Michael.Barton@asu.edu>
CC: grass-user@lists.osgeo.org
Betreff: Re: [GRASS-user] Problem with Python Scripts and

grass.script (GRASS 6.5SVN) on Mac

Hello again,

as recommended I removed the python.org-python (and removed the lines to
python.framework in the PATH.
When I now start python it is only the version 2.6.1 (also GRASS now

uses

this version) which should be the system-python. After removing the

other

python I recompiled the most recent version of GRASS 6.5, put my
mapcalc-testscript into the bin folder and tried to run it both, from

launch script

and from the GRASS-Terminal. But there is still the same error:

GRASS 6.5.svn (gisdemo_ncspm):~ > testscript.py newmap=test
elevation=elevation geology=geology
Traceback (most recent call last):
File "/Library/GRASS/6.5/Modules/bin/testscript.py", line 54, in
<module>
   sys.exit(main())
File "/Library/GRASS/6.5/Modules/bin/testscript.py", line 47, in main
   grass.mapcalc("${newmap} = ${elevation} * ${geology}",
AttributeError: 'module' object has no attribute 'mapcalc'

Here some addtional info from within the GRASS Terminal:
echo "$PYTHONPATH"
/Applications/GRASS-6.5.app/Contents/MacOS/etc/python

my sys.path (in GRASS-terminal python) is:
['', '/Library/Frameworks/SQLite3.framework/Versions/3/Python',
'/Library/Python/2.6/site-packages/numpy-override',
'/Library/Frameworks/GDAL.framework/Versions/1.8/Python/site-packages',
'/Library/Frameworks/cairo.framework/Versions/1/Python',
'/Applications/GRASS-6.5.app/Contents/MacOS/etc/python',

'/usr/local/lib/wxPython-unicode-2.8.11.0/lib/python2.6/site-packages',

'/usr/local/lib/wxPython-unicode-2.8.11.0/lib/python2.6/site-packages/wx-2.8-mac-unicode',

'/System/Library/Frameworks/Python.framework/Versions/2.6/lib/python26.zip',

'/System/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6',

'/System/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/plat-darwin',

'/System/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/plat-mac',

'/System/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/plat-mac/lib-scriptpackages',

'/System/Library/Frameworks/Python.framework/Versions/2.6/Extras/lib/python',

'/System/Library/Framewor
ks/Python.framework/Versions/2.6/lib/python2.6/lib-tk',

'/System/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/lib-old',

'/System/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/lib-dynload',

'/Library/Python/2.6/site-packages',
'/usr/local/lib/wxPython-unicode-2.8.11.0/lib/python2.6',

'/System/Library/Frameworks/Python.framework/Versions/2.6/Extras/lib/python/PyObjC',

'/System/Library/Frameworks/Python.framework/Versions/2.6/Extras/lib/python/wx-2.8-mac-unicode']

that is strange because there is no python.framework anymore so where

does

this come from?

The normal Terminal gives me for $PATH:

/opt/local/bin:/opt/local/sbin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/X11/bin

So maybe the sys.path is a hint for my problem...

/johannes

-------- Original-Nachricht --------

Datum: Sun, 3 Apr 2011 15:27:41 -0700
Von: Michael Barton <Michael.Barton@asu.edu>
An: Johannes Radinger <JRadinger@gmx.at>
CC: "grass-user@lists.osgeo.org" <grass-user@lists.osgeo.org>
Betreff: Re: [GRASS-user] Problem with Python Scripts and

grass.script (GRASS 6.5SVN) on Mac

When I and others have had a copy of Python from
python.org<http://python.org> installed, it has usually caused

problems,

including bogus errors. I

strongly advise against it. In theory, it should not be a problem, but

in

reality (in my experience) it IS a problem.

I can't say for sure that this is where your problem lies, but I'd be
suspicious. When you start python from the terminal, which one is it?

How about

from GRASS?

Michael
____________________
C. Michael Barton
Director, Center for Social Dynamics & Complexity
Professor of Anthropology, School of Human Evolution & Social Change
Arizona State University

voice: 480-965-6262 (SHESC), 480-727-9746 (CSDC)
fax: 480-965-7671 (SHESC), 480-727-0709 (CSDC)
www: http://www.public.asu.edu/~cmbarton, http://csdc.asu.edu

On Apr 3, 2011, at 12:23 PM, Johannes Radinger wrote:

Hello Glynn,
Hello Michael,

the answers to your suggestions/questions below:

Am 02.04.2011 um 17:24 schrieb Michael Barton:

Have you installed Python from python.org<http://python.org/&gt; on your

Mac?

If you have, there may be a problem with that.

Yes I there is python2.6.6 from python.org<http://python.org/&gt;

installed

but William Kyngesburye told me that this shouldn't be any
Problem and GRASS GIS can handle this, but I am not sure. Maybe I've

to

try to deinstall it, but I don't know how excatly so that everything

is

removed correctly also in the libs.

Michael
____________________
C. Michael Barton
Director, Center for Social Dynamics & Complexity
Professor of Anthropology, School of Human Evolution & Social Change
Arizona State University

voice: 480-965-6262 (SHESC), 480-727-9746 (CSDC)
fax: 480-965-7671 (SHESC), 480-727-0709 (CSDC)
www: http://www.public.asu.edu/~cmbarton,
http://csdc.asu.edu/&gt;

Am 03.04.2011 um 00:37 schrieb Glynn Clements:

Johannes Radinger wrote:

I tried to figure out the problem with william kyngesburye.
the script is also working on his mac. I saved the script in the bin
folder and ran in the GRASS terminal:

AttributeError: 'module' object has no attribute 'mapcalc'

What causes this AttributeError?

The grass.script module is either broken or very old (the mapcalc()
The GRASS build I've got is compiled from last weeks source (6.5)...

function was added in December 2008).

From within GRASS, try the following:

$ python

import grass.script as grass
print grass.__file__

that is what I get... does that help you?

/Applications/GRASS-6.5.app/Contents/MacOS/etc/python/grass/script/__init__.pyc

print grass.__path__

and for the path:
['/Applications/GRASS-6.5.app/Contents/MacOS/etc/python/grass/script']

/johannes

--
Glynn Clements

<glynn@gclements.plus.com<mailto:glynn@gclements.plus.com>>

_______________________________________________
grass-user mailing list
grass-user@lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/grass-user

--
NEU: FreePhone - kostenlos mobil telefonieren und surfen!
Jetzt informieren: http://www.gmx.net/de/go/freephone
_______________________________________________
grass-user mailing list
grass-user@lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/grass-user

--
NEU: FreePhone - kostenlos mobil telefonieren und surfen!
Jetzt informieren: http://www.gmx.net/de/go/freephone
_______________________________________________
grass-user mailing list
grass-user@lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/grass-user

--
Ihr GMX Postfach immer dabei: die kostenlose GMX Mail App für Android.
Komfortabel, sicher und schnell: www.gmx.de/android