[GRASS-user] Using grass.script in Jupyter (Azure)
varedi at gmail.com
Sat Oct 13 18:08:57 PDT 2018
Thanks for your email, I could run the following lines with no problem in
from IPython.display import Image
# create GRASS GIS runtime environment
gisbase = "f:\PROGRA~1\QGIS2~1.18\apps\grass\grass-7.4.1".strip()
os.environ['GISBASE'] = gisbase
sys.path.append(os.path.join(gisbase, "etc", "python"))
although when tried to run the following:
import grass.script as gs
import grass.script.setup as gsetup
again I got some errors:
ModuleNotFoundError Traceback (most recent call
in <module>() 38 # python2---> 39 import __builtin__
40 from os import environ
ModuleNotFoundError: No module named '__builtin__'
During handling of the above exception, another exception occurred:
ImportError Traceback (most recent call
last)<ipython-input-3-cd30798f91ed> in <module>()----> 1 import
grass.script as gs 2 import grass.script.setup as gsetup
in <module>() 3 from __future__ import absolute_import 4
----> 5 from .core import * 6 from .db import * 7 from
.raster import *
in <module>() 42 # python3 43 import builtins as
__builtin__---> 44 from os import environb as environ 45
unicode = str 46 __builtin__.__dict__['_'] =
ImportError: cannot import name 'environb' from 'os'
Do you have any idea why it is happening?
I have windows 10 on this machine and grass version 7.4.1 is installed.
On Wed, Oct 10, 2018 at 9:55 AM Vaclav Petras <wenzeslaus at gmail.com> wrote:
> On Tue, Oct 9, 2018 at 9:25 PM Mehrdad Varedi <varedi at gmail.com> wrote:
>> Hi Everyone,
>> I want to develop a program using GRASS python libraries in Jupyter(on
>> Azure). All codes begin with:
>> *import* *grass.script* *as* *gscript*
>> of course the grass.script is not available in Jupyter. I tried to
>> install GRASS
>> I used: !pip install GRASS
>> and it worked like a charm, although I can't have access to grass.script.
>> Sorry if it is a silly question, although I apreciate any idea to begin
>> programming GRASS on Azure.
> Hi Mehrdad,
> the package you installed is not GRASS GIS. Install GRASS GIS using
> whatever is appropriate for your platform (e.g. using apt install grass on
> Ubuntu, but ideally after connecting PPA in this case). Then there is
> couple of approaches how to use GRASS GIS with Jupyter. The one I prefer is
> starting Jupyter Notebook and than starting GRASS GIS from there:
> See also:
> [GRASS-dev] Package grass installed by pip is not GRASS GIS
>> I appreciate any help you can provide,
>> Mehrdad Varedi
>> grass-user mailing list
>> grass-user at lists.osgeo.org
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the grass-user