<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta name="Generator" content="Microsoft Word 15 (filtered medium)">
<!--[if !mso]><style>v\:* {behavior:url(#default#VML);}
o\:* {behavior:url(#default#VML);}
w\:* {behavior:url(#default#VML);}
.shape {behavior:url(#default#VML);}
</style><![endif]--><style><!--
/* Font Definitions */
@font-face
        {font-family:"Cambria Math";
        panose-1:2 4 5 3 5 4 6 3 2 4;}
@font-face
        {font-family:Calibri;
        panose-1:2 15 5 2 2 2 4 3 2 4;}
@font-face
        {font-family:Consolas;
        panose-1:2 11 6 9 2 2 4 3 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
        {margin:0cm;
        margin-bottom:.0001pt;
        font-size:11.0pt;
        font-family:"Calibri",sans-serif;
        color:black;}
h6
        {mso-style-priority:9;
        mso-style-link:"Heading 6 Char";
        mso-margin-top-alt:auto;
        margin-right:0cm;
        mso-margin-bottom-alt:auto;
        margin-left:0cm;
        font-size:7.5pt;
        font-family:"Calibri",sans-serif;
        color:black;
        font-weight:bold;}
a:link, span.MsoHyperlink
        {mso-style-priority:99;
        color:blue;
        text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
        {mso-style-priority:99;
        color:purple;
        text-decoration:underline;}
code
        {mso-style-priority:99;
        font-family:"Courier New";}
pre
        {mso-style-priority:99;
        mso-style-link:"HTML Preformatted Char";
        margin:0cm;
        margin-bottom:.0001pt;
        font-size:10.0pt;
        font-family:"Courier New";
        color:black;}
p.msonormal0, li.msonormal0, div.msonormal0
        {mso-style-name:msonormal;
        mso-margin-top-alt:auto;
        margin-right:0cm;
        mso-margin-bottom-alt:auto;
        margin-left:0cm;
        font-size:11.0pt;
        font-family:"Calibri",sans-serif;
        color:black;}
span.Heading6Char
        {mso-style-name:"Heading 6 Char";
        mso-style-priority:9;
        mso-style-link:"Heading 6";
        font-family:"Calibri Light",sans-serif;
        color:#1F3763;}
span.HTMLPreformattedChar
        {mso-style-name:"HTML Preformatted Char";
        mso-style-priority:99;
        mso-style-link:"HTML Preformatted";
        font-family:Consolas;
        color:black;}
span.EmailStyle23
        {mso-style-type:personal-reply;
        font-family:"Calibri",sans-serif;
        color:windowtext;}
.MsoChpDefault
        {mso-style-type:export-only;
        font-size:10.0pt;}
@page WordSection1
        {size:612.0pt 792.0pt;
        margin:70.85pt 70.85pt 70.85pt 70.85pt;}
div.WordSection1
        {page:WordSection1;}
--></style><!--[if gte mso 9]><xml>
<o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext="edit">
<o:idmap v:ext="edit" data="1" />
</o:shapelayout></xml><![endif]-->
</head>
<body bgcolor="white" lang="NO-BOK" link="blue" vlink="purple">
<div class="WordSection1">
<p class="MsoNormal"><span style="color:windowtext;mso-fareast-language:EN-US">Hi Robin,<o:p></o:p></span></p>
<p class="MsoNormal"><span style="color:windowtext;mso-fareast-language:EN-US"><o:p> </o:p></span></p>
<p class="MsoNormal"><span lang="EN-US" style="color:windowtext;mso-fareast-language:EN-US">After installing from python-fmask source as described I got the same error message as you did on:<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US" style="color:windowtext;mso-fareast-language:EN-US"><o:p> </o:p></span></p>
<p class="MsoNormal"><span lang="EN-US" style="color:windowtext;mso-fareast-language:EN-US">from fmask import fmask<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US" style="color:windowtext;mso-fareast-language:EN-US"><o:p> </o:p></span></p>
<p class="MsoNormal"><span lang="EN-US" style="color:windowtext;mso-fareast-language:EN-US">(just importing fmask worked also before).<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US" style="color:windowtext;mso-fareast-language:EN-US"><o:p> </o:p></span></p>
<p class="MsoNormal"><span lang="EN-US" style="color:windowtext;mso-fareast-language:EN-US">The problem seems to be that fmask (including it`s C components) gets installed in /usr/local/. See:<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US" style="color:windowtext;mso-fareast-language:EN-US"><a href="https://github.com/ubarsc/python-fmask/issues/19">https://github.com/ubarsc/python-fmask/issues/19</a><o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US" style="color:windowtext;mso-fareast-language:EN-US"><o:p> </o:p></span></p>
<p class="MsoNormal"><span lang="EN-US" style="color:windowtext;mso-fareast-language:EN-US">You can fix that by specifying /usr as a prefix during install:<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US" style="color:windowtext;mso-fareast-language:EN-US">sudo python3 setup.py install --prefix=/usr<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US" style="color:windowtext;mso-fareast-language:EN-US"><o:p> </o:p></span></p>
<p class="MsoNormal"><span lang="EN-US" style="color:windowtext;mso-fareast-language:EN-US">(note that I also had to specifically call setup.py with python3 which was an error in my initial installation script.)<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US" style="color:windowtext;mso-fareast-language:EN-US"><o:p> </o:p></span></p>
<p class="MsoNormal"><span lang="EN-US" style="color:windowtext;mso-fareast-language:EN-US">When python-fmask gets available on PyPi, I guess this will be taken care of…<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US" style="color:windowtext;mso-fareast-language:EN-US"><o:p> </o:p></span></p>
<p class="MsoNormal"><span lang="EN-US" style="color:windowtext;mso-fareast-language:EN-US">If you set the PYTHONPATH environment variable before starting GRASS GIS, GRASS should temporarily add the path to the GRASS python libs (but nothing more). If you use
 a prepackaged GRASS installation, it is compiled against a specific Python version (usually system Python). You can see which Python installation GRASS is using by typing:<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US" style="color:windowtext;mso-fareast-language:EN-US"><o:p> </o:p></span></p>
<p class="MsoNormal"><span lang="EN-US" style="color:windowtext;mso-fareast-language:EN-US">echo $GRASS_PYTHON<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US" style="color:windowtext;mso-fareast-language:EN-US"><o:p> </o:p></span></p>
<p class="MsoNormal"><span lang="EN-US" style="color:windowtext;mso-fareast-language:EN-US">So, if you want to use your conda Python in GRASS (despite possible issues other places), my understanding is that you would need to point GRASS_PYTHON variable to conda
 python. However, with the installation described above, GRASS should find fmask and _fillminima from fmask… In the long run, this will be the most convenient solution for an addon. For the time being, the installation procedure could be added to the manual
 as a note (and probably as an error message if import fails), until it becomes available on PyPi.<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US" style="color:windowtext;mso-fareast-language:EN-US"><o:p> </o:p></span></p>
<p class="MsoNormal"><span lang="EN-US" style="color:windowtext;mso-fareast-language:EN-US">Hope that helps.<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US" style="color:windowtext;mso-fareast-language:EN-US"><o:p> </o:p></span></p>
<p class="MsoNormal"><span lang="EN-US" style="color:windowtext;mso-fareast-language:EN-US">Cheers<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US" style="color:windowtext;mso-fareast-language:EN-US">Stefan<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US" style="color:windowtext;mso-fareast-language:EN-US"><o:p> </o:p></span></p>
<div>
<div style="border:none;border-top:solid #E1E1E1 1.0pt;padding:3.0pt 0cm 0cm 0cm">
<p class="MsoNormal"><b><span lang="EN-US" style="color:windowtext">From:</span></b><span lang="EN-US" style="color:windowtext"> robin <robin.kohrs@uni-jena.de>
<br>
<b>Sent:</b> søndag 5. april 2020 19:13<br>
<b>To:</b> Stefan Blumentrath <Stefan.Blumentrath@nina.no><br>
<b>Subject:</b> Re: [GRASS-user] Install package for add-on in /usr/bin/python3<o:p></o:p></span></p>
</div>
</div>
<p class="MsoNormal"><o:p> </o:p></p>
<div>
<p>Hi Stefan,<o:p></o:p></p>
<p>thank you very much!! Why does my <code><span style="font-size:9.5pt;font-family:Consolas;border:solid #EAEAEA 1.0pt;padding:0cm;background:#F8F8F8">PYTHONPATH</span></code> needs to point to the system-python? So the issue is, that I would like to have
 a script that I can run from within GRASS with <code><span style="font-size:9.5pt;font-family:Consolas;border:solid #EAEAEA 1.0pt;padding:0cm;background:#F8F8F8">launch user-defined script</span></code>. I created a conda environment (“spatial”) and installed
<code><span style="font-size:9.5pt;font-family:Consolas;border:solid #EAEAEA 1.0pt;padding:0cm;background:#F8F8F8">python-fmask</span></code> with:<o:p></o:p></p>
<p><code><span style="font-size:9.5pt;font-family:Consolas;border:solid #EAEAEA 1.0pt;padding:0cm;background:#F8F8F8">conda install -c conda-forge python-fmask</span></code><o:p></o:p></p>
<p>This automativally installes <code><span style="font-size:9.5pt;font-family:Consolas;border:solid #EAEAEA 1.0pt;padding:0cm;background:#F8F8F8">python3.8.2</span></code>,
<code><span style="font-size:9.5pt;font-family:Consolas;border:solid #EAEAEA 1.0pt;padding:0cm;background:#F8F8F8">fmask</span></code> and
<code><span style="font-size:9.5pt;font-family:Consolas;border:solid #EAEAEA 1.0pt;padding:0cm;background:#F8F8F8">rios</span></code> in:<o:p></o:p></p>
<p><code><span style="font-size:9.5pt;font-family:Consolas;border:solid #EAEAEA 1.0pt;padding:0cm;background:#F8F8F8">home/robin/miniconda3/envs/spatial/lib/python3.8/site-packages/</span></code><o:p></o:p></p>
<p>I then added this path in my .bashrc (I thought I needed to put it in the .profile, but this didn’t work for some reason) my
<code><span style="font-size:9.5pt;font-family:Consolas;border:solid #EAEAEA 1.0pt;padding:0cm;background:#F8F8F8">PYTHONPATH</span></code> with:<o:p></o:p></p>
<p><code><span style="font-size:9.5pt;font-family:Consolas;border:solid #EAEAEA 1.0pt;padding:0cm;background:#F8F8F8">export PYTHONPATH=/home/robin/miniconda3/envs/spatial/lib/python3.8/site-packages</span></code><o:p></o:p></p>
<p>I then did a <code><span style="font-size:9.5pt;font-family:Consolas;border:solid #EAEAEA 1.0pt;padding:0cm;background:#F8F8F8">source .bashrc</span></code> and when printing the
<code><span style="font-size:9.5pt;font-family:Consolas;border:solid #EAEAEA 1.0pt;padding:0cm;background:#F8F8F8">PYTHONPATH</span></code> with<o:p></o:p></p>
<p><code><span style="font-size:9.5pt;font-family:Consolas;border:solid #EAEAEA 1.0pt;padding:0cm;background:#F8F8F8">echo $PYTHONPATH</span></code> it prints<o:p></o:p></p>
<p><code><span style="font-size:9.5pt;font-family:Consolas;border:solid #EAEAEA 1.0pt;padding:0cm;background:#F8F8F8">/home/robin/miniconda3/envs/spatial/lib/python3.8/site-packages</span></code><o:p></o:p></p>
<p>I then made a little test script where I wanted to test if the fmask-import and rios-import works<br>
from within GRASS<o:p></o:p></p>
<h6 style="mso-margin-top-alt:15.6pt;margin-right:0cm;margin-bottom:12.0pt;margin-left:0cm" id="-">
<span style="font-size:11.0pt;color:#777777">#<o:p></o:p></span></h6>
<pre style="mso-margin-top-alt:0cm;margin-right:1.8pt;margin-bottom:0cm;margin-left:1.8pt;margin-bottom:.0001pt;line-height:14.4pt"><code><span style="font-size:9.5pt;font-family:Consolas;border:solid #CCCCCC 1.0pt;padding:6.0pt;background:#F8F8F8"><o:p> </o:p></span></code></pre>
<pre style="mso-margin-top-alt:0cm;margin-right:1.8pt;margin-bottom:0cm;margin-left:1.8pt;margin-bottom:.0001pt;line-height:14.4pt"><code><span style="font-size:9.5pt;font-family:Consolas;border:solid #CCCCCC 1.0pt;padding:6.0pt;background:#F8F8F8">  1 #! /usr/bin/env python3<o:p></o:p></span></code></pre>
<pre style="mso-margin-top-alt:0cm;margin-right:1.8pt;margin-bottom:0cm;margin-left:1.8pt;margin-bottom:.0001pt;line-height:14.4pt"><code><span style="font-size:9.5pt;font-family:Consolas;border:solid #CCCCCC 1.0pt;padding:6.0pt;background:#F8F8F8">  2<o:p></o:p></span></code></pre>
<pre style="mso-margin-top-alt:0cm;margin-right:1.8pt;margin-bottom:0cm;margin-left:1.8pt;margin-bottom:.0001pt;line-height:14.4pt"><code><span style="font-size:9.5pt;font-family:Consolas;border:solid #CCCCCC 1.0pt;padding:6.0pt;background:#F8F8F8">  3 import sys<o:p></o:p></span></code></pre>
<pre style="mso-margin-top-alt:0cm;margin-right:1.8pt;margin-bottom:0cm;margin-left:1.8pt;margin-bottom:.0001pt;line-height:14.4pt"><code><span style="font-size:9.5pt;font-family:Consolas;border:solid #CCCCCC 1.0pt;padding:6.0pt;background:#F8F8F8">  4 import os<o:p></o:p></span></code></pre>
<pre style="mso-margin-top-alt:0cm;margin-right:1.8pt;margin-bottom:0cm;margin-left:1.8pt;margin-bottom:.0001pt;line-height:14.4pt"><code><span style="font-size:9.5pt;font-family:Consolas;border:solid #CCCCCC 1.0pt;padding:6.0pt;background:#F8F8F8">  5<o:p></o:p></span></code></pre>
<pre style="mso-margin-top-alt:0cm;margin-right:1.8pt;margin-bottom:0cm;margin-left:1.8pt;margin-bottom:.0001pt;line-height:14.4pt"><code><span style="font-size:9.5pt;font-family:Consolas;border:solid #CCCCCC 1.0pt;padding:6.0pt;background:#F8F8F8">  6 for i in sys.path:<o:p></o:p></span></code></pre>
<pre style="mso-margin-top-alt:0cm;margin-right:1.8pt;margin-bottom:0cm;margin-left:1.8pt;margin-bottom:.0001pt;line-height:14.4pt"><code><span style="font-size:9.5pt;font-family:Consolas;border:solid #CCCCCC 1.0pt;padding:6.0pt;background:#F8F8F8">  7     print(i)<o:p></o:p></span></code></pre>
<pre style="mso-margin-top-alt:0cm;margin-right:1.8pt;margin-bottom:0cm;margin-left:1.8pt;margin-bottom:.0001pt;line-height:14.4pt"><code><span style="font-size:9.5pt;font-family:Consolas;border:solid #CCCCCC 1.0pt;padding:6.0pt;background:#F8F8F8">  8<o:p></o:p></span></code></pre>
<pre style="mso-margin-top-alt:0cm;margin-right:1.8pt;margin-bottom:0cm;margin-left:1.8pt;margin-bottom:.0001pt;line-height:14.4pt"><code><span style="font-size:9.5pt;font-family:Consolas;border:solid #CCCCCC 1.0pt;padding:6.0pt;background:#F8F8F8">  9 print("PYTHONPATH")<o:p></o:p></span></code></pre>
<pre style="mso-margin-top-alt:0cm;margin-right:1.8pt;margin-bottom:0cm;margin-left:1.8pt;margin-bottom:.0001pt;line-height:14.4pt"><code><span style="font-size:9.5pt;font-family:Consolas;border:solid #CCCCCC 1.0pt;padding:6.0pt;background:#F8F8F8"> 10 print(os.environ["PYTHONPATH"])<o:p></o:p></span></code></pre>
<pre style="mso-margin-top-alt:0cm;margin-right:1.8pt;margin-bottom:0cm;margin-left:1.8pt;margin-bottom:.0001pt;line-height:14.4pt"><code><span style="font-size:9.5pt;font-family:Consolas;border:solid #CCCCCC 1.0pt;padding:6.0pt;background:#F8F8F8"> 11<o:p></o:p></span></code></pre>
<pre style="mso-margin-top-alt:0cm;margin-right:1.8pt;margin-bottom:0cm;margin-left:1.8pt;margin-bottom:.0001pt;line-height:14.4pt"><code><span style="font-size:9.5pt;font-family:Consolas;border:solid #CCCCCC 1.0pt;padding:6.0pt;background:#F8F8F8"> 12 import fmask<o:p></o:p></span></code></pre>
<pre style="mso-margin-top-alt:0cm;margin-right:1.8pt;margin-bottom:0cm;margin-left:1.8pt;margin-bottom:.0001pt;line-height:14.4pt"><code><span style="font-size:9.5pt;font-family:Consolas;border:solid #CCCCCC 1.0pt;padding:6.0pt;background:#F8F8F8"> 13 import rios<o:p></o:p></span></code></pre>
<pre style="mso-margin-top-alt:0cm;margin-right:1.8pt;margin-bottom:0cm;margin-left:1.8pt;margin-bottom:.0001pt;line-height:14.4pt"><code><span style="font-size:9.5pt;font-family:Consolas;border:solid #CCCCCC 1.0pt;padding:6.0pt;background:#F8F8F8"> 13 import rios<o:p></o:p></span></code></pre>
<h6 style="mso-margin-top-alt:15.6pt;margin-right:0cm;margin-bottom:12.0pt;margin-left:0cm" id="-">
<span style="font-size:11.0pt;color:#777777">#<o:p></o:p></span></h6>
<p>When importing this script in GRASS with the “launch user-defined script”-option, the output is:<o:p></o:p></p>
<pre style="mso-margin-top-alt:0cm;margin-right:1.8pt;margin-bottom:0cm;margin-left:1.8pt;margin-bottom:.0001pt;line-height:14.4pt"><code><span style="font-size:9.5pt;font-family:Consolas;border:solid #CCCCCC 1.0pt;padding:6.0pt;background:#F8F8F8">/home/robin/Desktop<o:p></o:p></span></code></pre>
<pre style="mso-margin-top-alt:0cm;margin-right:1.8pt;margin-bottom:0cm;margin-left:1.8pt;margin-bottom:.0001pt;line-height:14.4pt"><code><span style="font-size:9.5pt;font-family:Consolas;border:solid #CCCCCC 1.0pt;padding:6.0pt;background:#F8F8F8">/usr/lib/grass78/etc/python<o:p></o:p></span></code></pre>
<pre style="mso-margin-top-alt:0cm;margin-right:1.8pt;margin-bottom:0cm;margin-left:1.8pt;margin-bottom:.0001pt;line-height:14.4pt"><code><span style="font-size:9.5pt;font-family:Consolas;border:solid #CCCCCC 1.0pt;padding:6.0pt;background:#F8F8F8">/usr/lib/python36.zip<o:p></o:p></span></code></pre>
<pre style="mso-margin-top-alt:0cm;margin-right:1.8pt;margin-bottom:0cm;margin-left:1.8pt;margin-bottom:.0001pt;line-height:14.4pt"><code><span style="font-size:9.5pt;font-family:Consolas;border:solid #CCCCCC 1.0pt;padding:6.0pt;background:#F8F8F8">/usr/lib/python3.6<o:p></o:p></span></code></pre>
<pre style="mso-margin-top-alt:0cm;margin-right:1.8pt;margin-bottom:0cm;margin-left:1.8pt;margin-bottom:.0001pt;line-height:14.4pt"><code><span style="font-size:9.5pt;font-family:Consolas;border:solid #CCCCCC 1.0pt;padding:6.0pt;background:#F8F8F8">/usr/lib/python3.6/lib-dynload<o:p></o:p></span></code></pre>
<pre style="mso-margin-top-alt:0cm;margin-right:1.8pt;margin-bottom:0cm;margin-left:1.8pt;margin-bottom:.0001pt;line-height:14.4pt"><code><span style="font-size:9.5pt;font-family:Consolas;border:solid #CCCCCC 1.0pt;padding:6.0pt;background:#F8F8F8">/home/robin/.local/lib/python3.6/site-packages<o:p></o:p></span></code></pre>
<pre style="mso-margin-top-alt:0cm;margin-right:1.8pt;margin-bottom:0cm;margin-left:1.8pt;margin-bottom:.0001pt;line-height:14.4pt"><code><span style="font-size:9.5pt;font-family:Consolas;border:solid #CCCCCC 1.0pt;padding:6.0pt;background:#F8F8F8">/usr/local/lib/python3.6/dist-packages<o:p></o:p></span></code></pre>
<pre style="mso-margin-top-alt:0cm;margin-right:1.8pt;margin-bottom:0cm;margin-left:1.8pt;margin-bottom:.0001pt;line-height:14.4pt"><code><span style="font-size:9.5pt;font-family:Consolas;border:solid #CCCCCC 1.0pt;padding:6.0pt;background:#F8F8F8">/usr/lib/python3/dist-packages<o:p></o:p></span></code></pre>
<pre style="mso-margin-top-alt:0cm;margin-right:1.8pt;margin-bottom:0cm;margin-left:1.8pt;margin-bottom:.0001pt;line-height:14.4pt"><code><span style="font-size:9.5pt;font-family:Consolas;border:solid #CCCCCC 1.0pt;padding:6.0pt;background:#F8F8F8">PYTHONPATH<o:p></o:p></span></code></pre>
<pre style="mso-margin-top-alt:0cm;margin-right:1.8pt;margin-bottom:0cm;margin-left:1.8pt;margin-bottom:.0001pt;line-height:14.4pt"><code><span style="font-size:9.5pt;font-family:Consolas;border:solid #CCCCCC 1.0pt;padding:6.0pt;background:#F8F8F8">/usr/lib/grass78/etc/python<o:p></o:p></span></code></pre>
<pre style="mso-margin-top-alt:0cm;margin-right:1.8pt;margin-bottom:0cm;margin-left:1.8pt;margin-bottom:.0001pt;line-height:14.4pt"><code><span style="font-size:9.5pt;font-family:Consolas;border:solid #CCCCCC 1.0pt;padding:6.0pt;background:#F8F8F8">Traceback (most recent call last):<o:p></o:p></span></code></pre>
<pre style="mso-margin-top-alt:0cm;margin-right:1.8pt;margin-bottom:0cm;margin-left:1.8pt;margin-bottom:.0001pt;line-height:14.4pt"><code><span style="font-size:9.5pt;font-family:Consolas;border:solid #CCCCCC 1.0pt;padding:6.0pt;background:#F8F8F8">  File "/home/robin/Desktop/test.py", line 12, in <module><o:p></o:p></span></code></pre>
<pre style="mso-margin-top-alt:0cm;margin-right:1.8pt;margin-bottom:0cm;margin-left:1.8pt;margin-bottom:.0001pt;line-height:14.4pt"><code><span style="font-size:9.5pt;font-family:Consolas;border:solid #CCCCCC 1.0pt;padding:6.0pt;background:#F8F8F8">    import fmask<o:p></o:p></span></code></pre>
<pre style="mso-margin-top-alt:0cm;margin-right:1.8pt;margin-bottom:0cm;margin-left:1.8pt;margin-bottom:.0001pt;line-height:14.4pt"><code><span style="font-size:9.5pt;font-family:Consolas;border:solid #CCCCCC 1.0pt;padding:6.0pt;background:#F8F8F8">ModuleNotFoundError: No module named 'fmask'<o:p></o:p></span></code></pre>
<p>I don’t know why the <code><span style="font-size:9.5pt;font-family:Consolas;border:solid #EAEAEA 1.0pt;padding:0cm;background:#F8F8F8">PYTHONPATH</span></code> is different when run from GRASS. Probably I’m just not understanding something really basic.
 If so I’m really sorry. It’s just a little frustrating to spend so much time in something so basic.<o:p></o:p></p>
<p>Anyways: Thanks so much for the help!<br>
Cheers,<br>
Robin<o:p></o:p></p>
<p>On 05.04.2020 14:35, Stefan Blumentrath wrote:<o:p></o:p></p>
<div>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<div>
<p class="MsoNormal" style="margin-bottom:12.0pt"><span style="font-family:"Arial",sans-serif">Did you check that your pythonpath again points to system python. And can you share your code, esp. the imports. That would simplify testing...<o:p></o:p></span></p>
</div>
<div>
<div>
<p class="MsoNormal"><span style="font-family:"Arial",sans-serif">Sent from <a href="https://aka.ms/blhgte">
Outlook Mobile</a><o:p></o:p></span></p>
</div>
<p class="MsoNormal"><span style="font-family:"Arial",sans-serif"><o:p> </o:p></span></p>
</div>
<div class="MsoNormal" align="center" style="text-align:center">
<hr size="2" width="98%" align="center">
</div>
<div id="divRplyFwdMsg">
<p class="MsoNormal"><b>From:</b> robin kohrs <a href="mailto:robin.kohrs@uni-jena.de">
<robin.kohrs@uni-jena.de></a><br>
<b>Sent:</b> Sunday, April 5, 2020 11:04:02 AM<br>
<b>To:</b> Stefan Blumentrath <a href="mailto:Stefan.Blumentrath@nina.no"><Stefan.Blumentrath@nina.no></a><br>
<b>Subject:</b> Re: [GRASS-user] Install package for add-on in /usr/bin/python3 <o:p>
</o:p></p>
<div>
<p class="MsoNormal"> <o:p></o:p></p>
</div>
</div>
<div>
<div>
<p class="MsoNormal">Hi Stefan,<br>
<br>
thank you very much for the answer! That would be great if it'd become a <br>
standard python package!<br>
I managed to install everything as you explained it. But when I run:<br>
<br>
In [1]: from fmask import fmask<br>
<br>
I still get<br>
<br>
ModuleNotFoundError: No module named 'rios'<br>
<br>
I guess this is, because they are still in seperate folders right?<br>
When I copy everything from the installed rios into fmask (I know this <br>
seems really wrong...) and then do :<br>
<br>
In [2]: from fmask import fmask<br>
<br>
ImportError: cannot import name '_fillminima'<br>
<br>
I'm sorry for these basic questions, but I just can't find a solution:/<br>
<br>
cheers and thanks a lot!!<br>
Robin<br>
<br>
On 04.04.20 20:56, Stefan Blumentrath wrote:<br>
> Hi Robin,<br>
><br>
> The errors you encountered after setting the python path, occurred because fmask depends on another, non-standard Python package, namely rios (that would have to be added to the PYTHONPATH as well).<br>
><br>
> Yet, it seems there is some more interest in getting python-fmask (and thus also RIOS) available as a standard python package. See:
<a href="https://github.com/ubarsc/python-fmask/issues/30">https://github.com/ubarsc/python-fmask/issues/30</a><br>
> So, your problem might get solved "upstreams".<br>
><br>
> Meanwhile you could install both packages manually into your standard Python installation as follows:<br>
><br>
> wget <a href="https://github.com/ubarsc/rios/releases/download/rios-1.4.10/rios-1.4.10.zip">
https://github.com/ubarsc/rios/releases/download/rios-1.4.10/rios-1.4.10.zip</a><br>
> unzip rios-1.4.10.zip<br>
> cd rios-1.4.10/<br>
> sudo python setup.py install<br>
> cd ..<br>
><br>
> wget <a href="https://github.com/ubarsc/python-fmask/releases/download/pythonfmask-0.5.4/python-fmask-0.5.4.zip">
https://github.com/ubarsc/python-fmask/releases/download/pythonfmask-0.5.4/python-fmask-0.5.4.zip</a><br>
> unzip -q python-fmask-0.5.4.zip<br>
> cd python-fmask-0.5.4/<br>
> python setup.py build<br>
> sudo python setup.py install<br>
><br>
> For me (on Ubuntu 18.04) this gives:<br>
><br>
> $ ipython<br>
> Python 3.6.8 (default, Oct  7 2019, 12:59:55)<br>
> Type 'copyright', 'credits' or 'license' for more information<br>
> IPython 7.13.0 -- An enhanced Interactive Python. Type '?' for help.<br>
><br>
> In [1]: import fmask<br>
><br>
> In [2]: fmask.__version__<br>
> Out[2]: '0.5.4'<br>
><br>
> In [3]: import rios<br>
><br>
> In [4]: rios.__version__<br>
> Out[4]: '1.4.10'<br>
><br>
> Cheers<br>
> Stefan<br>
><br>
><br>
> -----Original Message-----<br>
> From: Robin Kohrs <a href="mailto:robin.kohrs@uni-jena.de"><robin.kohrs@uni-jena.de></a><br>
> Sent: tirsdag 31. mars 2020 15:42<br>
> To: Stefan Blumentrath <a href="mailto:Stefan.Blumentrath@nina.no"><Stefan.Blumentrath@nina.no></a><br>
> Cc: Markus Neteler <a href="mailto:neteler@osgeo.org"><neteler@osgeo.org></a>; GRASS user list
<a href="mailto:grass-user@lists.osgeo.org"><grass-user@lists.osgeo.org></a><br>
> Subject: Re: [GRASS-user] Install package for add-on in /usr/bin/python3<br>
><br>
> Hi Stefan,<br>
><br>
> thank you very much for the effort and the patience in answering!<br>
> I'll definitely give this a try. I already have so many issues on my computer, one more doesn't matter;)<br>
><br>
> thanks again and best regards,<br>
> Robin<br>
><br>
> Citando Stefan Blumentrath <a href="mailto:Stefan.Blumentrath@nina.no"><Stefan.Blumentrath@nina.no></a>:<br>
><br>
>> Hi Robin,<br>
>><br>
>> You could try setting the GRASS_PYTHON environment variable to your<br>
>> Python installation with fmask.<br>
>><br>
>> import os<br>
>> os.environ['GRASS_PYTHON'] = '/YOUR/PYTHON/PATH'<br>
>><br>
>> As Markus indicates that can cause other issues.<br>
>><br>
>> You may also have a look at <a href="https://github.com/zarch/grass-session">https://github.com/zarch/grass-session</a><br>
>> for inspiration.<br>
>><br>
>> Hope that gives you at least a lead...<br>
>><br>
>> Cheers<br>
>> Stefan<br>
>><br>
>><br>
>> -----Original Message-----<br>
>> From: grass-user <a href="mailto:grass-user-bounces@lists.osgeo.org"><grass-user-bounces@lists.osgeo.org></a> On Behalf Of<br>
>> Robin Kohrs<br>
>> Sent: tirsdag 31. mars 2020 09:25<br>
>> To: Markus Neteler <a href="mailto:neteler@osgeo.org"><neteler@osgeo.org></a><br>
>> Cc: GRASS user list <a href="mailto:grass-user@lists.osgeo.org"><grass-user@lists.osgeo.org></a><br>
>> Subject: Re: [GRASS-user] Install package for add-on in<br>
>> /usr/bin/python3<br>
>><br>
>> Hi Markus,<br>
>><br>
>> thank you very much for your answer and the help!<br>
>> Do you have any idea what I could do to make the fmask-package<br>
>> "locatable" for the python-interpreter that grass is using?<br>
>><br>
>> I tried the following options, but I guess I just don't know<br>
>> sufficiently about how python and grass really work together:<br>
>><br>
>> My python-script looks more or less like this:<br>
>> ---------------------------------------<br>
>> #!/usr/bin/env python3<br>
>><br>
>> import sys<br>
>><br>
>> print("SYS PATH")<br>
>> print(sys.path)<br>
>> print("")<br>
>> print("SYS EXECUTABLE")<br>
>> print(sys.executable)<br>
>><br>
>> import grass.script as grass<br>
>> from rios import fileinfo # that's where it fails from fmask import<br>
>> fmask<br>
>><br>
>> ---------------------------------------<br>
>><br>
>> That's why I tried until now:<br>
>><br>
>> - I created an environment with conda and installed python-fmask via<br>
>> "conda install -c conda-forge python-fmask". The function<br>
>> "fmask_sentinel2Stacked.py" lies in<br>
>> "/home/robin/miniconda3/bin/fmask_sentinel2Stacked.py".<br>
>><br>
>> - When I open an interactive python-shell and import fmask and rios<br>
>> and the type: "fmask.__file__" it gives me<br>
>> "/home/robin/miniconda3/envs/fmask/lib/python3.7/site-packages/fmask/__init__.py"<br>
>><br>
>> - I then added<br>
>> "/home/robin/miniconda3/envs/fmask/lib/python3.7/site-packages/" to<br>
>> the variable PYTHONPATH in my .bashrc<br>
>><br>
>> - When I now start the interpreter that grass uses from the command<br>
>> line by typing "/usr/bin/pyton3" I can import fmask and rios<br>
>><br>
>> - However when I run the script with grass it always says that there<br>
>> is no package names rios. Moreover the path I added to PYTHONPATH is<br>
>> not printed when it executes "sys.path" in my grass script<br>
>><br>
>><br>
>> I'm sorry for this little confusing question. But in case someone<br>
>> has any idea how I could make grass find fmask, would be super highly<br>
>> appreciated:)<br>
>><br>
>> thanks a lot in advance! Cheers<br>
>> Robin<br>
>><br>
>> Citando Markus Neteler <a href="mailto:neteler@osgeo.org"><neteler@osgeo.org></a>:<br>
>><br>
>>> Hi Robin,<br>
>>><br>
>>> On Sat, Mar 21, 2020 at 6:15 PM Robin Kohrs <a href="mailto:robin.kohrs@uni-jena.de">
<robin.kohrs@uni-jena.de></a> wrote:<br>
>>>><br>
>>>> Hi everyone:)<br>
>>>> I'm really sorry for this naive question. I'm kind of starting with<br>
>>>> GRASS and I just can't find a solution...<br>
>>>> The issue is, that I would like to try to write a little GRASS Add-on<br>
>>>> and use the python-fmask package. While this package is only<br>
>>>> downloadable via conda it always installs into<br>
>>>> `/home/user/miniconda3/bin/python3`. Even when I did `conda<br>
>>>> deactivate` prior to this.<br>
>>> I guess that mixing conda packages and "regular" ones is causing troubles.<br>
>>><br>
>>>> When I then have the import statement `import fask` in the<br>
>>>> grass-script it always throws an error, saying that fmask is not<br>
>>>> installed. When I print the `sys.executable` in the grass-script it<br>
>>>> tells me that the interpreter is in `usr/bin/python3`. So I thought<br>
>>>> that I'd install the fmask-package in a way that this interpreter can<br>
>>>> find it while executing the script. But I just don't know how. I can<br>
>>>> add the fmask-path to sys.path, but I don't think this is the<br>
>>>> solution. Maybe someone has a pointer what I'm not getting.<br>
>>> There is also the environment variable PYTHONPATH which could be set<br>
>>> in the session.<br>
>>> But again, mixing might cause problems.<br>
>>><br>
>>> Now I wanted to check<br>
>>> <a href="http://pythonfmask.org/en/latest/#downloads">http://pythonfmask.org/en/latest/#downloads</a><br>
>>> but the server is down...<br>
>>><br>
>>>> Hope everyone is good these days:)!<br>
>>> Good luck everyone,<br>
>>><br>
>>> Markus<br>
>><br>
>><br>
>> _______________________________________________<br>
>> grass-user mailing list<br>
>> <a href="mailto:grass-user@lists.osgeo.org">grass-user@lists.osgeo.org</a><br>
>> <a href="https://lists.osgeo.org/mailman/listinfo/grass-user">https://lists.osgeo.org/mailman/listinfo/grass-user</a><br>
><br>
><o:p></o:p></p>
</div>
</div>
</blockquote>
</div>
<div>
<p class="MsoNormal"><span style="font-size:1.0pt">​<o:p></o:p></span></p>
</div>
</div>
</div>
</body>
</html>