Coder Social home page Coder Social logo

g.extension vs r.green about grass-addons HOT 19 OPEN

osgeo avatar osgeo commented on July 18, 2024
g.extension vs r.green

from grass-addons.

Comments (19)

neteler avatar neteler commented on July 18, 2024

I suppose it is an addon bug since other addons can be installed.

The replacement of python with python3 is needed in g.extension.

from grass-addons.

jachym avatar jachym commented on July 18, 2024

My estimation is, that the is some "strange character" in the input file, so that replace fails. Maybe replacing just the first line would help. This can occur in any future extension

Also, if on non-Linux platform (aka windows), the replacement is not necessary, since Windows ignore it, right?

from grass-addons.

tmszi avatar tmszi commented on July 18, 2024

My estimation is, that the is some "strange character" in the input file, so that replace fails. Maybe replacing just the first line would help. This can occur in any future extension

Yes it is. Lambda symbol and others. fileinput.FileInput() method open file with default OS system encoding. It is possible define openhook param arg (using the given encoding), but not with inplace=True param arg. On GNU/Linux, I did not notice any problem with the installation of the r.green extension.

Also, if on non-Linux platform (aka windows), the replacement is not necessary, since Windows ignore it, right?

from grass-addons.

neteler avatar neteler commented on July 18, 2024

Shall we replace those "offending" symbols in r.green or modify anything else? Any suggestion, @zarch ?

from grass-addons.

tmszi avatar tmszi commented on July 18, 2024

If commented out in g.extension (as mentioned above), r.green module installation work:

# for filename in pyfiles:
#    with fileinput.FileInput(filename, inplace=True) as file:
#        for line in file:
#            print(line.replace(
#                "#!/usr/bin/env python\n",
#                "#!/usr/bin/env python3\n"
#            ), end='')

But rendering special symbol in module ui is incorrect on MS WIndows (wxMSW).

r.green.gshp.technical module ui, OS MS Windows (wxMSW)

r_green_gshp_technical_wxmsw

wxPython use default encoding (according locale):

import wx
locale = wx.Locale()
locale.GetSystemEncodingName()
windows-1252

Lambda symbol is UTF-8.

r.green.gshp.technical module ui, OS GNU/Linux (wxGTK)

r_green_gshp_technical_wxgtk

wxPython use default encoding (according locale):

import wx
locale = wx.Locale()
locale.GetSystemEncodingName()
UTF-8

I think it would be appropriate to replace these special symbols.

from grass-addons.

neteler avatar neteler commented on July 18, 2024

Any suggestion how to deal with this?

from grass-addons.

anissa293 avatar anissa293 commented on July 18, 2024

hello, i encountered similar issue when installing r.green addons, and no issue on installing other addons. i'm using grass 7.8.3 on windows. any help to solve this issue? I saw

If commented out in g.extension (as mentioned above), r.green module installation work:

# for filename in pyfiles:
#    with fileinput.FileInput(filename, inplace=True) as file:
#        for line in file:
#            print(line.replace(
#                "#!/usr/bin/env python\n",
#                "#!/usr/bin/env python3\n"
#            ), end='')

But rendering special symbol in module ui is incorrect on MS WIndows (wxMSW).

r.green.gshp.technical module ui, OS MS Windows (wxMSW)

r_green_gshp_technical_wxmsw

r.green.gshp.technical module ui, OS GNU/Linux (wxGTK)

r_green_gshp_technical_wxgtk

I think it would be appropriate to replace these special symbols.

How do we put this on command console? after the error message?

from grass-addons.

tmszi avatar tmszi commented on July 18, 2024

hello, i encountered similar issue when installing r.green addons, and no issue on installing other addons. i'm using grass 7.8.3 on windows. any help to solve this issue? I saw
How do we put this on command console? after the error message?

Hello, here's how to install r.green Add-On (OS MS Windows, WIn GRASS GIS 7.8.3 installation).

  1. Launch your favourite text editor (Notepad++...) with Admin rights.
  2. Open in text editor this file C:\Program Files\GRASS GIS 7.8\scripts\g.extension.py
  3. Go to line code 1148 comment this lines (1148-1154 including): when you find this uncommented code (code bellow in the install_extension_win() function) and comment them (according code below):
# for filename in pyfiles:
#     with fileinput.FileInput(filename, inplace=True) as file:
#         for line in file:
#             print(line.replace(
#                 "#!/usr/bin/env python\n",
#                 "#!/usr/bin/env python3\n"
#             ), end='')
  1. Save edited file
  2. Install r.green Add-On with command: g.extension r.green or via GUI
  3. Try launch some r.green module e.g. r.green.gshp.technical

from grass-addons.

anissa293 avatar anissa293 commented on July 18, 2024

hello @tmszi thank you very much for the response!

I did exactly as you said however it still doesnt work out

below is the edited g.extension py
Capture

and the same error message once i try to install the r.green
Capture 1

from grass-addons.

tmszi avatar tmszi commented on July 18, 2024

hello @tmszi thank you very much for the response!

I did exactly as you said however it still doesnt work out

below is the edited g.extension py
Capture

and the same error message once i try to install the r.green
Capture 1

I think you have another GRASS GIS version than I have and therefore line numbers (step no. 3 in my previous message) aren't correct.

According screenshot with error you send go to line 1055, and you will see this code:

    for filename in pyfiles:
        with fileinput.FileInput(filename, inplace=True) as file:
            for line in file:
                print(line.replace(
                    "#!/usr/bin/env python\n",
                    "#!/usr/bin/env python3\n"
                ), end='')

and comment this lines (add # comment symbol before these lines)

    # for filename in pyfiles:
    #     with fileinput.FileInput(filename, inplace=True) as file:
    #         for line in file:
    #             print(line.replace(
    #                 "#!/usr/bin/env python\n",
    #                 "#!/usr/bin/env python3\n"
    #             ), end='')

from grass-addons.

anissa293 avatar anissa293 commented on July 18, 2024

it works perfectly now! thanks a lot @tmszi

from grass-addons.

tmszi avatar tmszi commented on July 18, 2024

it works perfectly now! thanks a lot @tmszi

You are welcome :-).

from grass-addons.

anissa293 avatar anissa293 commented on July 18, 2024

hi @tmszi and all,

I have managed to install the r.green addon and run some modules. However when i tried to run the r.green.hydro.optimal, error message on the scipy requirement appeared:
WARNING: You should install scipy to use this module: pip install scipy
WARNING: You should install scipy to use this module: pip install scipy
WARNING: You should install scipy to use this module: pip install scipy
WARNING: You should install scipy to use this module: pip install scipy
Traceback (most recent call last):
File "C:\Users\ANIA\AppData\Roaming\GRASS7\addons/scripts/
r.green.hydro.optimal.py", line 189, in
sys.exit(main(options, flags))
File "C:\Users\ANIA\AppData\Roaming\GRASS7\addons/scripts/
r.green.hydro.optimal.py", line 180, in main
p_max)
File "C:\Users\ANIA\AppData\Roaming\GRASS7\addons\etc\r.gr
een\libhydro\optimal.py", line 357, in find_segments
count, p_max)
File "C:\Users\ANIA\AppData\Roaming\GRASS7\addons\etc\r.gr
een\libhydro\optimal.py", line 231, in recursive_plant
cat, line, count, p_max)
File "C:\Users\ANIA\AppData\Roaming\GRASS7\addons\etc\r.gr
een\libhydro\optimal.py", line 243, in check_plant
fun_h = interpolate.interp1d(prog, h,
bounds_error=False, fill_value=0)
NameError: name 'interpolate' is not defined
(Tue Oct 13 11:46:33 2020) Command finished (1 sec)

I have installed scipy and numpy as required and it shown in the command below:
Capture 1

Appreciate it very much if anyone could help me on this matter. I have very little to none knowledge on python

from grass-addons.

baharmon avatar baharmon commented on July 18, 2024

from grass-addons.

anissa293 avatar anissa293 commented on July 18, 2024

hi @baharmon i did exactly as you said and the same error message still appear.
WARNING: You should install scipy to use this module: pip install scipy
WARNING: You should install scipy to use this module: pip install scipy

Is there a way to check of whether scipy is properly installed and detected by Grass?

from grass-addons.

anissa293 avatar anissa293 commented on July 18, 2024

I already tried to check in Grass terminal btw, and it says that I have scipy. Unsure why this warning message appears :(
Capture 1

Capture

from grass-addons.

tmszi avatar tmszi commented on July 18, 2024

hi @tmszi and all,

I have managed to install the r.green addon and run some modules. However when i tried to run the r.green.hydro.optimal, error message on the scipy requirement appeared:

Hi anissa293, here's how to install python additional scipy lib (OS MS Windows, Standalone Win GRASS GIS 7.8 installation). I tested on 64 bit OS Win 10, with Standalone GRASS GIS 64 bit installer.

  1. Download numpy and scipy windows binary package from this page Unofficial Windows Binaries for Python Extension Packages.
    Choose between 32/64 bit according your GRASS GIS installation.
    1.1 64 bit GRASS GIS version: numpy, scipy
    1.2 32 bit GRASS GIS version: numpy, scipy

  2. GRASS GIS is distributed with own Python version. First launch new cmd (command line program) with Admin rights. Change dir with following command in cmd:

cd "C:\Program Files\GRASS GIS 7.8\Python37"
  1. Install numpy python bin lib first with following command in the cmd:

Change PATH_TO_DOWNLOADED_NUMPY_WHL_FILE to the right path (my path is e.g. C:\Users\IEUser\Desktop\numpy-1.18.5+mkl-cp37-cp37m-win_amd64.whl)

python.exe Scripts\pip3.exe install PATH_TO_DOWNLOADED_NUMPY_WHL_FILE
  1. Install scipy python bin lib with following command in the cmd:

Change PATH_TO_DOWNLOADED_SCIPY_WHL_FILE to the right path (my path is e.g. C:\Users\IEUser\Desktop\scipy-1.4.1-cp37-cp37m-win_amd64.whl)

python.exe Scripts\pip3.exe install PATH_TO_DOWNLOADED_SCIPY_WHL_FILE
  1. Launch GRASS GIS and r.green module r.green.hydro.optimal

from grass-addons.

tmszi avatar tmszi commented on July 18, 2024

I already tried to check in Grass terminal btw, and it says that I have scipy. Unsure why this warning message appears :(

If you want verify that GRASS GIS Python has scipy lib installed (GRASS GIS has own Python in the installation directory: C:\Program Files\GRASS GIS 7.8\Python37) :

  1. Launch cmd
  2. Change dir in cmd cd "C:\Program Files\GRASS GIS 7.8\Python37"
  3. Get list of installed Python libs python.exe Scripts\pip3.exe freeze list

Or simple way via GUI Python shell (Layer Manager -> Python tab)

  1. import scipy (run without error)

from grass-addons.

anissa293 avatar anissa293 commented on July 18, 2024

Hi anissa293, here's how to install python additional scipy lib (OS MS Windows, Standalone Win GRASS GIS 7.8 installation). I tested on 64 bit OS Win 10, with Standalone GRASS GIS 64 bit installer.

hi @tmszi it finally works! thanks a lot for this. I also checked again the scipy lib in Grass Python is installed. Hopefully no more issues after this fingercrossed
Capture 1

from grass-addons.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.