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

Johannes Radinger JRadinger at gmx.at
Mon Apr 4 08:40:42 EDT 2011


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 at gmx.at>
> An: Michael.Barton at asu.edu
> CC: grass-user at 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 at gmx.at>
> > An: Michael Barton <Michael.Barton at asu.edu>
> > CC: grass-user at 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 at asu.edu>
> > > An: Johannes Radinger <JRadinger at gmx.at>
> > > CC: "grass-user at lists.osgeo.org" <grass-user at 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/> 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/>
> 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<http://csdc.asu.edu/>
> > > 
> > > 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 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
> > 
> > -- 
> > NEU: FreePhone - kostenlos mobil telefonieren und surfen!			
> > Jetzt informieren: http://www.gmx.net/de/go/freephone
> > _______________________________________________
> > grass-user mailing list
> > grass-user at 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 at 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


More information about the grass-user mailing list