Hi Vaclav, Thanks for your email, I could run the following lines with no problem in Jupyter:
import os import sys import subprocess 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 last)f:\PROGRA~1\QGIS2~1.18\apps\grass\grass-7.4.1\etc\python\grass\script\core.py 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 f:\PROGRA~1\QGIS2~1.18\apps\grass\grass-7.4.1\etc\python\grass\script\__init__.py in <module>() 3 from __future__ import absolute_import 4 ----> 5 from .core import * 6 from .db import * 7 from .raster import * f:\PROGRA~1\QGIS2~1.18\apps\grass\grass-7.4.1\etc\python\grass\script\core.py in <module>() 42 # python3 43 import builtins as __builtin__---> 44 from os import environb as environ 45 unicode = str 46 __builtin__.__dict__['_'] = __builtin__.__dict__['_'].__self__.lgettext ImportError: cannot import name 'environb' from 'os' (f:\ProgramData\Anaconda3\lib\os.py) Do you have any idea why it is happening? I have windows 10 on this machine and grass version 7.4.1 is installed. Thanks, Mehrdad ᐧ On Wed, Oct 10, 2018 at 9:55 AM Vaclav Petras <[email protected]> wrote: > > > On Tue, Oct 9, 2018 at 9:25 PM Mehrdad Varedi <[email protected]> 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: > > > https://github.com/wenzeslaus/geospatial-modeling-course-jupyter/blob/master/notebooks/buffers_cost_python.ipynb > > See also: > > [GRASS-dev] Package grass installed by pip is not GRASS GIS > https://lists.osgeo.org/pipermail/grass-dev/2018-October/090191.html > > Best, > Vaclav > > >> I appreciate any help you can provide, >> >> >> >> Mehrdad >> >> -- >> >> Mehrdad Varedi >> ᐧ >> _______________________________________________ >> grass-user mailing list >> [email protected] >> https://lists.osgeo.org/mailman/listinfo/grass-user > > -- Mehrdad Varedi
_______________________________________________ grass-user mailing list [email protected] https://lists.osgeo.org/mailman/listinfo/grass-user
