[GRASS-user] need to run python-grass script outside grass in Unix environment
Vaclav Petras
wenzeslaus at gmail.com
Tue May 31 18:22:48 PDT 2016
[returning the conversation to the mailing list]
On Tue, May 31, 2016 at 7:35 PM, alassane toure <atourej at gmail.com> wrote:
> I am having problem with the launch session...
>
> # launch session
> rcfile = gscript.setup.init(gisbase, gisdb, location, mapset)
>
> See the system response below..
>
> /Programs/grass/rshade$ /home/alassane/Programs/grass/rshade/testing.py
> Traceback (most recent call last):
> File "/home/alassane/Programs/grass/rshade/testing.py", line 70, in
> <module>
> rcfile = gscript.setup.init(gisbase, gisdb, location, mapset)
> AttributeError: 'module' object has no attribute 'setup'
>
The example was wrong. The `__init__.py` of `script` does not `import
setup`:
https://trac.osgeo.org/grass/browser/grass/trunk/lib/python/script/__init__.py
So, the import needs to be done explicitly:
import grass.script.setup as gsetup
rcfile = gsetup.init(gisbase, gisdb, location, mapset)
The documentation fixed in:
https://trac.osgeo.org/grass/changeset/68547
Please test.
Vaclav
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/grass-user/attachments/20160531/38cf796e/attachment.html>
More information about the grass-user
mailing list