[prev in list] [next in list] [prev in thread] [next in thread] 

List:       grass-user
Subject:    Re: [GRASS-user] Running a python script using GRASS GIS on a Mac
From:       Shaffiq Somani <ssomani () msn ! com>
Date:       2021-11-24 5:16:44
Message-ID: E043F1D4-B724-4CF4-AE4A-EAD1243386C7 () msn ! com
[Download RAW message or body]

[Attachment #2 (text/plain)]

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"
 bash-3.2$ export GISRC="/Applications/GRASS-7.8.app/Contents/Resources/demolocation/.grassrc78"
 bash-3.2$ export PATH="/Applications/GRASS-7.8.app/Contents/Resources/lib:/Applicatio \
ns/GRASS-7.8.app/Contents/Resources/bin:/Applications/GRASS-7.8.app/Contents/Resources/scripts"
 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'

Please let me know if you have any suggestions.  Thanks so much for your assistance.

Kind Regards,

Shaffiq


On Nov 23, 2021, at 1:13 AM, Moritz Lennert \
<mlennert@club.worldonline.be<mailto:mlennert@club.worldonline.be>> wrote:

Hi Shaffiq,

First of all please try to avoid using screenshots of the command line. You should be \
able to just copy-paste it's contents as text into your email which makes it much \
easier to read on most devices.

Le 23 novembre 2021 05:26:22 GMT+01:00, Shaffiq Somani \
<SSomani@msn.com<mailto:SSomani@msn.com>> a écrit : Dear Moritz,

Thank you for your response since its greatly appreciated.  Sorry, I just saw your \
message since it went into the spam folder.  I have a couple of questions for you if \
you have a moment free.  I looked at the Linux environmental variables which is \
export GRASS_BIN=/usr/bin/grass78, ​but changed it to GRASSBASE and opened up the \
unix file as shown in the screenshot below.  I still get the following errors. Is \
there anything else that I am missing or should I be doing this another way.  Thanks.

AFAIK, GRASSBASE is not used in GRASS GIS. Where did you get that from.

I would suggest to set that back to GRASSBIN and try again.

Moritz


________________________________
From: Moritz Lennert \
                <mlennert@club.worldonline.be<mailto:mlennert@club.worldonline.be>>
Sent: Monday, November 22, 2021 2:16 AM
To: grass-user@lists.osgeo.org<mailto:grass-user@lists.osgeo.org> \
<grass-user@lists.osgeo.org<mailto:grass-user@lists.osgeo.org>>; Shaffiq Somani \
                <ssomani@msn.com<mailto:ssomani@msn.com>>
Subject: Re: [GRASS-user] Running a python script using GRASS GIS on a Mac

Hi Shaffiq,


Le 22 novembre 2021 00:48:04 GMT+01:00, Shaffiq Somani \
<ssomani@msn.com<mailto:ssomani@msn.com>> a écrit : Dear GRASS Community,

I am trying to run grass as a Python script  for the gapfilling component of PySEBAL \
where the GitHub directory is shown below.   I have already imported the \
grass-session using the pip3 command.

PySEBAL GitHub Directory GapFilling
https://na01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fspareeth \
%2FPySEBAL_dev%2Ftree%2Fversion3.7.3%2Fgapfilling&amp;data=04%7C01%7C%7Cd44fe3d6f6b847 \
4c3bdd08d9ae50d315%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C637732484430999647%7CU \
nknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3 \
D%7C3000&amp;sdata=qfwHowFWkSjB7A00qJOqqF6CBVIQwx0U%2FwFKDYaa0EA%3D&amp;reserved=0

The Windows Environmental Variable setup file is shown below which I tried to follow \
in the  Jupyter Notebook and  see if I can import GRASS.  Unfortunately, I had no \
luck as shown in the screenshot.

set GRASSBIN=C:\OSGeo4W64\bin\grass78


As you can see here, GRASSBIN points to the actual 'binary' file that contains the \
GRASS GIS launch script (grass78). In your example it seems to me that you only point \
to the directory that contains it, not the actual file. Try adding the name of the \
file to your path.

Moritz


[Attachment #3 (text/html)]

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
</head>
<body style="word-wrap: break-word; -webkit-nbsp-mode: space; line-break: \
after-white-space;" class=""> Dear Moritz,
<div class=""><br class="">
</div>
<div class="">Thank you for your advise and I just cut and paste the text from the \
terminal. &nbsp;I am making a bit of progress, as shown in the text below. &nbsp;I am \
not sure why it can't find the grass_session as I installed it using the PIP command. \
&nbsp;The only solution  I can think of is that &nbsp;GRASS is using its own version \
of Python and not the Anaconda version.</div> <div class=""><br class="">
</div>
<div class="">
<div style="margin: 0px; font-stretch: normal; font-size: 11px; line-height: normal; \
font-family: Menlo; color: rgb(0, 0, 0);" class=""> <br class="">
</div>
<div style="margin: 0px; font-stretch: normal; line-height: normal; font-family: \
Menlo; color: rgb(0, 0, 0);" class=""> <div style="margin: 0px; font-stretch: normal; \
line-height: normal;" class=""><span style="font-variant-ligatures: \
no-common-ligatures;" class="">bash-3.2$ export \
GRASSBASE=&quot;/Applications/GRASS-7.8.app/Contents/Resources/bin/grass78&quot;&nbsp;</span></div>
 <div style="margin: 0px; font-stretch: normal; line-height: normal;" class=""><span \
style="font-variant-ligatures: no-common-ligatures" class="">bash-3.2$ export \
GISRC=&quot;/Applications/GRASS-7.8.app/Contents/Resources/demolocation/.grassrc78&quot;</span></div>
 <div style="margin: 0px; font-stretch: normal; line-height: normal;" class=""><span \
style="font-variant-ligatures: no-common-ligatures" class="">bash-3.2$ export \
PATH=&quot;/Applications/GRASS-7.8.app/Contents/Resources/lib:/Applications/GRASS-7.8. \
app/Contents/Resources/bin:/Applications/GRASS-7.8.app/Contents/Resources/scripts&quot;</span></div>
 <div style="margin: 0px; font-stretch: normal; line-height: normal;" class=""><span \
style="font-variant-ligatures: no-common-ligatures" class="">bash-3.2$ python \
gapfill_v3.py</span></div> <div style="margin: 0px; font-stretch: normal; \
line-height: normal;" class=""><span style="font-variant-ligatures: \
no-common-ligatures" class="">['/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']</span></div>
 <div style="margin: 0px; font-stretch: normal; line-height: normal;" class=""><span \
style="font-variant-ligatures: no-common-ligatures" class="">Traceback (most recent \
call last):</span></div> <div style="margin: 0px; font-stretch: normal; line-height: \
normal;" class=""><span style="font-variant-ligatures: no-common-ligatures" \
class="">&nbsp; File &quot;gapfill_v3.py&quot;, line 20, in \
&lt;module&gt;</span></div> <div style="margin: 0px; font-stretch: normal; \
line-height: normal;" class=""><span style="font-variant-ligatures: \
no-common-ligatures" class="">&nbsp; &nbsp; import grass_session</span></div> <div \
style="margin: 0px; font-stretch: normal; line-height: normal;" class=""><span \
style="font-variant-ligatures: no-common-ligatures;" class="">ModuleNotFoundError: No \
module named ‘grass_session'</span></div> <div style="margin: 0px; font-stretch: \
normal; line-height: normal;" class=""><span style="font-variant-ligatures: \
no-common-ligatures;" class=""><br class=""> </span></div>
<div style="margin: 0px; font-stretch: normal; line-height: normal;" class=""><span \
style="font-variant-ligatures: no-common-ligatures;" class="">Please let me know if \
you have any suggestions. &nbsp;Thanks so much for your assistance.</span></div> <div \
style="margin: 0px; font-stretch: normal; line-height: normal;" class=""><span \
style="font-variant-ligatures: no-common-ligatures;" class=""><br class=""> \
</span></div> <div style="margin: 0px; font-stretch: normal; line-height: normal;" \
class=""><span style="font-variant-ligatures: no-common-ligatures;" class="">Kind \
Regards,</span></div> <div style="margin: 0px; font-stretch: normal; line-height: \
normal;" class=""><span style="font-variant-ligatures: no-common-ligatures;" \
class=""><br class=""> </span></div>
<div style="margin: 0px; font-stretch: normal; line-height: normal;" class=""><span \
style="font-variant-ligatures: no-common-ligatures;" class="">Shaffiq</span></div> \
</div> </div>
<div class=""><br class="">
<div><br class="">
<blockquote type="cite" class="">
<div class="">On Nov 23, 2021, at 1:13 AM, Moritz Lennert &lt;<a \
href="mailto:mlennert@club.worldonline.be" \
class="">mlennert@club.worldonline.be</a>&gt; wrote:</div> <br \
class="Apple-interchange-newline"> <div class="">
<div class="">Hi Shaffiq,<br class="">
<br class="">
First of all please try to avoid using screenshots of the command line. You should be \
able to just copy-paste it's contents as text into your email which makes it much \
easier to read on most devices.<br class=""> <br class="">
Le 23 novembre 2021 05:26:22 GMT+01:00, Shaffiq Somani &lt;<a \
href="mailto:SSomani@msn.com" class="">SSomani@msn.com</a>&gt; a écrit&nbsp;:<br \
class=""> <blockquote type="cite" class="">Dear Moritz,<br class="">
<br class="">
Thank you for your response since its greatly appreciated. &nbsp;Sorry, I just saw \
your message since it went into the spam folder. &nbsp;I have a couple of questions \
for you if you have a moment free. &nbsp;I looked at the Linux environmental \
variables which is export GRASS_BIN=/usr/bin/grass78,  ​but changed it to GRASSBASE \
and opened up the unix file as shown in the screenshot below. &nbsp;I still get the \
following errors. Is there anything else that I am missing or should I be doing this \
another way. &nbsp;Thanks.<br class=""> </blockquote>
<br class="">
AFAIK, GRASSBASE is not used in GRASS GIS. Where did you get that from.<br class="">
<br class="">
I would suggest to set that back to GRASSBIN and try again.<br class="">
<br class="">
Moritz<br class="">
<br class="">
<br class="">
<blockquote type="cite" class="">________________________________<br class="">
From: Moritz Lennert &lt;<a href="mailto:mlennert@club.worldonline.be" \
                class="">mlennert@club.worldonline.be</a>&gt;<br class="">
Sent: Monday, November 22, 2021 2:16 AM<br class="">
To: <a href="mailto:grass-user@lists.osgeo.org" \
class="">grass-user@lists.osgeo.org</a> &lt;<a \
href="mailto:grass-user@lists.osgeo.org" class="">grass-user@lists.osgeo.org</a>&gt;; \
Shaffiq Somani &lt;<a href="mailto:ssomani@msn.com" \
                class="">ssomani@msn.com</a>&gt;<br class="">
Subject: Re: [GRASS-user] Running a python script using GRASS GIS on a Mac<br \
class=""> <br class="">
Hi Shaffiq,<br class="">
<br class="">
<br class="">
Le 22 novembre 2021 00:48:04 GMT+01:00, Shaffiq Somani &lt;<a \
href="mailto:ssomani@msn.com" class="">ssomani@msn.com</a>&gt; a écrit :<br \
class=""> <blockquote type="cite" class="">Dear GRASS Community,<br class="">
<br class="">
I am trying to run grass as a Python script &nbsp;for the gapfilling component of \
PySEBAL where the GitHub directory is shown below. &nbsp;&nbsp;I have already \
imported the grass-session using the pip3 command.<br class=""> <br class="">
PySEBAL GitHub Directory GapFilling<br class="">
<a href="https://na01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2 \
Fspareeth%2FPySEBAL_dev%2Ftree%2Fversion3.7.3%2Fgapfilling&amp;amp;data=04%7C01%7C%7Cd \
44fe3d6f6b8474c3bdd08d9ae50d315%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C637732484 \
430999647%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwi \
LCJXVCI6Mn0%3D%7C3000&amp;amp;sdata=qfwHowFWkSjB7A00qJOqqF6CBVIQwx0U%2FwFKDYaa0EA%3D&amp;amp;reserved=0" \
class="">https://na01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2 \
Fspareeth%2FPySEBAL_dev%2Ftree%2Fversion3.7.3%2Fgapfilling&amp;amp;data=04%7C01%7C%7Cd \
44fe3d6f6b8474c3bdd08d9ae50d315%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C637732484 \
430999647%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwi \
LCJXVCI6Mn0%3D%7C3000&amp;amp;sdata=qfwHowFWkSjB7A00qJOqqF6CBVIQwx0U%2FwFKDYaa0EA%3D&amp;amp;reserved=0</a><br \
class=""> <br class="">
The Windows Environmental Variable setup file is shown below which I tried to follow \
in the &nbsp;Jupyter Notebook and &nbsp;see if I can import GRASS. \
&nbsp;Unfortunately, I had no luck as shown in the screenshot.<br class=""> <br \
class=""> set GRASSBIN=C:\OSGeo4W64\bin\grass78<br class="">
</blockquote>
<br class="">
<br class="">
As you can see here, GRASSBIN points to the actual 'binary' file that contains the \
GRASS GIS launch script (grass78). In your example it seems to me that you only point \
to the directory that contains it, not the actual file. Try adding the name of the \
file  to your path.<br class="">
<br class="">
Moritz<br class="">
<br class="">
</blockquote>
</div>
</div>
</blockquote>
</div>
<br class="">
</div>
</body>
</html>



_______________________________________________
grass-user mailing list
grass-user@lists.osgeo.org
https://lists.osgeo.org/mailman/listinfo/grass-user

--===============0613843268309575323==--

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic