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

Shaffiq Somani SSomani at msn.com
Sat Dec 4 11:27:46 PST 2021


Dear Moritz,

Thanks about GRASSBIN as I missed it.  I was able to install grass_session since one of the errors I was making was with the PATH variable.  I overwrote the PATH variable instead of append. 

I still need to test the grass_session since the python file was producing an error.  Not sure if that’s the python file running on the Mac or there’s another issue with grass_session.  I think there is enough example items on the web to determine which is which.  

Thanks for all your help. 

Kind Regards,

Shaffiq 
Sent from my iPhone

> On Dec 2, 2021, at 5:48 AM, Moritz Lennert <mlennert at club.worldonline.be> wrote:
> 
> 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