[GRASS-user] Running a python script using GRASS GIS on a Mac

Moritz Lennert mlennert at club.worldonline.be
Thu Dec 2 03:48:31 PST 2021


Hi Shaffiq,

Am 24.11.2021 06:16 schrieb Shaffiq Somani:
> Dear Moritz,
> 
> Thank you for your advise and I just cut and paste the text from the
> terminal. I am making a bit of progress, as shown in the text below. I
> am not sure why it can’t find the grass_session as I installed it
> using the PIP command. The only solution I can think of is that GRASS
> is using its own version of Python and not the Anaconda version.
> 
> bash-3.2$ export
> GRASSBASE="/Applications/GRASS-7.8.app/Contents/Resources/bin/grass78"

As mentioned earlier, GRASSBASE is not used. This should be GRASSBIN. 
GRASSBIN is a variable used by grass_session to find the correct GRASS 
GIS binary.

> 
> bash-3.2$ python gapfill_v3.py
> ['/Users/shaffiqsomani/PySEBAL_dev/gapfilling',
> '/Applications/GRASS-7.8.app/Contents/Resources/lib/python38.zip',
> '/Applications/GRASS-7.8.app/Contents/Resources/lib/python3.8',
> '/Applications/GRASS-7.8.app/Contents/Resources/lib/python3.8/lib-dynload',
> '/Applications/GRASS-7.8.app/Contents/Resources/lib/python3.8/site-packages']
> 
> Traceback (most recent call last):
>  File "gapfill_v3.py", line 20, in <module>
>  import grass_session
> ModuleNotFoundError: No module named ‘grass_session’
> 

Are you sure that you have grass_session installed ? It is independent 
of GRASS GIS, so needs to be installed separately.
Could you just open a terminal, launch the python interpreter, just type 
'import grass_session' in there and tell us what happens ?

Moritz


More information about the grass-user mailing list