[GRASS-user] grass-user Digest, Vol 224, Issue 1

Hey Michael & Vanessa,

Wrangling Python packages can be a bit tricky. Especially if you’re dealing with virtual environments. Installing packages through pip could cause your dependencies to conflict between projects. That being said, Anaconda’s conda does have its own pitfalls, especially if you’re part of an organization larger than 200 people that uses Anaconda’s channels (the conda-forge channel is exempt from this since it is community run).

Vanessa will have to create a python environment through conda or pixi and add grass/scikit-learn to the same environment. I’d recommend pixi instead of having to reconfigure conda to point to new channels. If you’re only able to work with conda, I’d recommend creating a new environment and putting both of those dependencies into their own project.

Here’s the instructions from the osgeo-forge grass-feedstock.

conda config --add channels conda-forge

If you want to install both packages into your ‘base’ environment on Anaconda. But I highly recommend you at least create a new environment and install your packages there.

conda install grass scikit-learn

With pixi:

pixi init
cd
pixi add python grass scikit-learn
pixi shell

Thank you,
Gregory

On Tue, Dec 17, 2024 at 3:01 PM <grass-user-request@lists.osgeo.org> wrote:

Send grass-user mailing list submissions to
grass-user@lists.osgeo.org

To subscribe or unsubscribe via the World Wide Web, visit
https://lists.osgeo.org/mailman/listinfo/grass-user
or, via email, send a message with subject or body ‘help’ to
grass-user-request@lists.osgeo.org

You can reach the person managing the list at
grass-user-owner@lists.osgeo.org

When replying, please edit your Subject line so it is more specific
than “Re: Contents of grass-user digest…”

Today’s Topics:

  1. Python in GRASS on Windows (Michael Barton)

Message: 1
Date: Tue, 17 Dec 2024 16:53:04 +0000
From: Michael Barton <Michael.Barton@asu.edu>
To: GRASS users <grass-user@lists.osgeo.org>, GRASS developers
<grass-dev@discourse.osgeo.org>
Cc: Vanessa Extrem <Vanessa.Extrem@uv.es>
Subject: [GRASS-user] Python in GRASS on Windows
Message-ID: <12319197-5F56-4841-AC64-1F9FB946BBB5@asu.edu>
Content-Type: text/plain; charset=“us-ascii”

I have a student who is interested in using some of the modeling tools available in GRASS extensions. These require some Python tools (e.g., scikit-learn) to be installed in her GRASS environments.

For me (on a Mac), I can just pip install -U scikit-learn from the GRASS terminal. But when she does this, the Windows terminal can’t find pip. This seems to be just a path problem but I don’t know how to troubleshoot it on Windows. She has installed Python via Anaconda and can use Python in GRASS via the Python console, but this does not seem to help in this case (conda can’t be found from the GRASS Windows terminal). Can someone point us to a guide of how to install Python packages into the GRASS environment on Windows and/or adjust the path so that the Windows terminal can access Python utilities?

Thanks
Michael


C. Michael Barton
Associate Director, School of Complex Adaptive Systems (https://scas.asu.edu<https://scas.asu.edu/>)
Professor, School of Human Evolution & Social Change (https://shesc.asu.edu)
Director, Center for Social Dynamics & Complexity (https://complexity.asu.edu)
Arizona State University
Tempe, AZ 85287-2701
USA

Executive Director, Open Modeling Foundation (https://openmodelingfoundation.github.io<https://openmodelingfoundation.github.io/>)
Director, Network for Computational Modeling in Social & Ecological Sciences (https://comses.net)

personal website: http://www.public.asu.edu/~cmbarton

-------------- next part --------------
An HTML attachment was scrubbed…
URL: <http://lists.osgeo.org/pipermail/grass-user/attachments/20241217/44ad7971/attachment-0001.htm>


Subject: Digest Footer


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


End of grass-user Digest, Vol 224, Issue 1


Disregard the previous, it appears the grass conda-forge feedstock isn’t alive. Let me do some digging and get back to you.

On Tue, Dec 17, 2024 at 5:53 PM Gregory Power <gregorywpower@gmail.com> wrote:

Hey Michael & Vanessa,

Wrangling Python packages can be a bit tricky. Especially if you’re dealing with virtual environments. Installing packages through pip could cause your dependencies to conflict between projects. That being said, Anaconda’s conda does have its own pitfalls, especially if you’re part of an organization larger than 200 people that uses Anaconda’s channels (the conda-forge channel is exempt from this since it is community run).

Vanessa will have to create a python environment through conda or pixi and add grass/scikit-learn to the same environment. I’d recommend pixi instead of having to reconfigure conda to point to new channels. If you’re only able to work with conda, I’d recommend creating a new environment and putting both of those dependencies into their own project.

Here’s the instructions from the osgeo-forge grass-feedstock.

conda config --add channels conda-forge

If you want to install both packages into your ‘base’ environment on Anaconda. But I highly recommend you at least create a new environment and install your packages there.

conda install grass scikit-learn

With pixi:

pixi init
cd
pixi add python grass scikit-learn
pixi shell

Thank you,
Gregory

On Tue, Dec 17, 2024 at 3:01 PM <grass-user-request@lists.osgeo.org> wrote:

Send grass-user mailing list submissions to
grass-user@lists.osgeo.org

To subscribe or unsubscribe via the World Wide Web, visit
https://lists.osgeo.org/mailman/listinfo/grass-user
or, via email, send a message with subject or body ‘help’ to
grass-user-request@lists.osgeo.org

You can reach the person managing the list at
grass-user-owner@lists.osgeo.org

When replying, please edit your Subject line so it is more specific
than “Re: Contents of grass-user digest…”

Today’s Topics:

  1. Python in GRASS on Windows (Michael Barton)

Message: 1
Date: Tue, 17 Dec 2024 16:53:04 +0000
From: Michael Barton <Michael.Barton@asu.edu>
To: GRASS users <grass-user@lists.osgeo.org>, GRASS developers
<grass-dev@discourse.osgeo.org>
Cc: Vanessa Extrem <Vanessa.Extrem@uv.es>
Subject: [GRASS-user] Python in GRASS on Windows
Message-ID: <12319197-5F56-4841-AC64-1F9FB946BBB5@asu.edu>
Content-Type: text/plain; charset=“us-ascii”

I have a student who is interested in using some of the modeling tools available in GRASS extensions. These require some Python tools (e.g., scikit-learn) to be installed in her GRASS environments.

For me (on a Mac), I can just pip install -U scikit-learn from the GRASS terminal. But when she does this, the Windows terminal can’t find pip. This seems to be just a path problem but I don’t know how to troubleshoot it on Windows. She has installed Python via Anaconda and can use Python in GRASS via the Python console, but this does not seem to help in this case (conda can’t be found from the GRASS Windows terminal). Can someone point us to a guide of how to install Python packages into the GRASS environment on Windows and/or adjust the path so that the Windows terminal can access Python utilities?

Thanks
Michael


C. Michael Barton
Associate Director, School of Complex Adaptive Systems (https://scas.asu.edu<https://scas.asu.edu/>)
Professor, School of Human Evolution & Social Change (https://shesc.asu.edu)
Director, Center for Social Dynamics & Complexity (https://complexity.asu.edu)
Arizona State University
Tempe, AZ 85287-2701
USA

Executive Director, Open Modeling Foundation (https://openmodelingfoundation.github.io<https://openmodelingfoundation.github.io/>)
Director, Network for Computational Modeling in Social & Ecological Sciences (https://comses.net)

personal website: http://www.public.asu.edu/~cmbarton

-------------- next part --------------
An HTML attachment was scrubbed…
URL: <http://lists.osgeo.org/pipermail/grass-user/attachments/20241217/44ad7971/attachment-0001.htm>


Subject: Digest Footer


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


End of grass-user Digest, Vol 224, Issue 1


Thanks Gregory. Currently, our issue is making sure that relevant Python packages are accessible within an operating GRASS environment, which is distinct from a general Windows environment.

Michael


C. Michael Barton
Associate Director, School of Complex Adaptive Systems (https://scas.asu.edu)
Professor, School of Human Evolution & Social Change (https://shesc.asu.edu)
Director, Center for Social Dynamics & Complexity (https://complexity.asu.edu)
Arizona State University
Tempe, AZ 85287-2701
USA

Executive Director, Open Modeling Foundation (https://openmodelingfoundation.github.io)
Director, Network for Computational Modeling in Social & Ecological Sciences (https://comses.net)

personal website: http://www.public.asu.edu/~cmbarton

On Dec 17, 2024, at 4:34 PM, Gregory Power gregorywpower@gmail.com wrote:

Disregard the previous, it appears the grass conda-forge feedstock isn’t alive. Let me do some digging and get back to you.

On Tue, Dec 17, 2024 at 5:53 PM Gregory Power <gregorywpower@gmail.com> wrote:

Hey Michael & Vanessa,

Wrangling Python packages can be a bit tricky. Especially if you’re dealing with virtual environments. Installing packages through pip could cause your dependencies to conflict between projects. That being said, Anaconda’s conda does have its own pitfalls, especially if you’re part of an organization larger than 200 people that uses Anaconda’s channels (the conda-forge channel is exempt from this since it is community run).

Vanessa will have to create a python environment through conda or pixi and add grass/scikit-learn to the same environment. I’d recommend pixi instead of having to reconfigure conda to point to new channels. If you’re only able to work with conda, I’d recommend creating a new environment and putting both of those dependencies into their own project.

Here’s the instructions from the osgeo-forge grass-feedstock.

conda config --add channels conda-forge

If you want to install both packages into your ‘base’ environment on Anaconda. But I highly recommend you at least create a new environment and install your packages there.

conda install grass scikit-learn

With pixi:

pixi init
cd
pixi add python grass scikit-learn
pixi shell

Thank you,
Gregory

On Tue, Dec 17, 2024 at 3:01 PM <grass-user-request@lists.osgeo.org> wrote:

Send grass-user mailing list submissions to
grass-user@lists.osgeo.org

To subscribe or unsubscribe via the World Wide Web, visit
https://lists.osgeo.org/mailman/listinfo/grass-user
or, via email, send a message with subject or body ‘help’ to
grass-user-request@lists.osgeo.org

You can reach the person managing the list at
grass-user-owner@lists.osgeo.org

When replying, please edit your Subject line so it is more specific
than “Re: Contents of grass-user digest…”

Today’s Topics:

  1. Python in GRASS on Windows (Michael Barton)

Message: 1
Date: Tue, 17 Dec 2024 16:53:04 +0000
From: Michael Barton <Michael.Barton@asu.edu>
To: GRASS users <grass-user@lists.osgeo.org>, GRASS developers
<grass-dev@discourse.osgeo.org>
Cc: Vanessa Extrem <Vanessa.Extrem@uv.es>
Subject: [GRASS-user] Python in GRASS on Windows
Message-ID: <12319197-5F56-4841-AC64-1F9FB946BBB5@asu.edu>
Content-Type: text/plain; charset=“us-ascii”

I have a student who is interested in using some of the modeling tools available in GRASS extensions. These require some Python tools (e.g., scikit-learn) to be installed in her GRASS environments.

For me (on a Mac), I can just pip install -U scikit-learn from the GRASS terminal. But when she does this, the Windows terminal can’t find pip. This seems to be just a path problem but I don’t know how to troubleshoot it on Windows. She has installed Python via Anaconda and can use Python in GRASS via the Python console, but this does not seem to help in this case (conda can’t be found from the GRASS Windows terminal). Can someone point us to a guide of how to install Python packages into the GRASS environment on Windows and/or adjust the path so that the Windows terminal can access Python utilities?

Thanks
Michael


C. Michael Barton
Associate Director, School of Complex Adaptive Systems (https://scas.asu.edu<https://scas.asu.edu/>)
Professor, School of Human Evolution & Social Change (https://shesc.asu.edu)
Director, Center for Social Dynamics & Complexity (https://complexity.asu.edu)
Arizona State University
Tempe, AZ 85287-2701
USA

Executive Director, Open Modeling Foundation (https://openmodelingfoundation.github.io<https://openmodelingfoundation.github.io/>)
Director, Network for Computational Modeling in Social & Ecological Sciences (https://comses.net)

personal website: http://www.public.asu.edu/~cmbarton

-------------- next part --------------
An HTML attachment was scrubbed…
URL: <http://lists.osgeo.org/pipermail/grass-user/attachments/20241217/44ad7971/attachment-0001.htm>


Subject: Digest Footer


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


End of grass-user Digest, Vol 224, Issue 1


I just want to make sure I’m understanding you properly, you’re trying to access conda environments from inside the grass shell? They may need to open up a Powershell prompt, type “where.exe conda” copy the path that command spits out into their “Path” environment variable—which they can do at the “system” level or “user” level.

On Tue, Dec 17, 2024 at 18:52 Michael Barton <Michael.Barton@asu.edu> wrote:

Thanks Gregory. Currently, our issue is making sure that relevant Python packages are accessible within an operating GRASS environment, which is distinct from a general Windows environment.

Michael


C. Michael Barton
Associate Director, School of Complex Adaptive Systems (https://scas.asu.edu)
Professor, School of Human Evolution & Social Change (https://shesc.asu.edu)
Director, Center for Social Dynamics & Complexity (https://complexity.asu.edu)
Arizona State University
Tempe, AZ 85287-2701
USA

Executive Director, Open Modeling Foundation (https://openmodelingfoundation.github.io)

Director, Network for Computational Modeling in Social & Ecological Sciences (https://comses.net)

personal website: http://www.public.asu.edu/~cmbarton

On Dec 17, 2024, at 4:34 PM, Gregory Power <gregorywpower@gmail.com> wrote:

Disregard the previous, it appears the grass conda-forge feedstock isn’t alive. Let me do some digging and get back to you.

On Tue, Dec 17, 2024 at 5:53 PM Gregory Power <gregorywpower@gmail.com> wrote:

Hey Michael & Vanessa,

Wrangling Python packages can be a bit tricky. Especially if you’re dealing with virtual environments. Installing packages through pip could cause your dependencies to conflict between projects. That being said, Anaconda’s conda does have its own pitfalls, especially if you’re part of an organization larger than 200 people that uses Anaconda’s channels (the conda-forge channel is exempt from this since it is community run).

Vanessa will have to create a python environment through conda or pixi and add grass/scikit-learn to the same environment. I’d recommend pixi instead of having to reconfigure conda to point to new channels. If you’re only able to work with conda, I’d recommend creating a new environment and putting both of those dependencies into their own project.

Here’s the instructions from the osgeo-forge grass-feedstock.

conda config --add channels conda-forge

If you want to install both packages into your ‘base’ environment on Anaconda. But I highly recommend you at least create a new environment and install your packages there.

conda install grass scikit-learn

With pixi:

pixi init
cd
pixi add python grass scikit-learn
pixi shell

Thank you,
Gregory

On Tue, Dec 17, 2024 at 3:01 PM <grass-user-request@lists.osgeo.org> wrote:

Send grass-user mailing list submissions to
grass-user@lists.osgeo.org

To subscribe or unsubscribe via the World Wide Web, visit
https://lists.osgeo.org/mailman/listinfo/grass-user
or, via email, send a message with subject or body ‘help’ to
grass-user-request@lists.osgeo.org

You can reach the person managing the list at
grass-user-owner@lists.osgeo.org

When replying, please edit your Subject line so it is more specific
than “Re: Contents of grass-user digest…”

Today’s Topics:

  1. Python in GRASS on Windows (Michael Barton)

Message: 1
Date: Tue, 17 Dec 2024 16:53:04 +0000
From: Michael Barton <Michael.Barton@asu.edu>
To: GRASS users <grass-user@lists.osgeo.org>, GRASS developers
<grass-dev@discourse.osgeo.org>
Cc: Vanessa Extrem <Vanessa.Extrem@uv.es>
Subject: [GRASS-user] Python in GRASS on Windows
Message-ID: <12319197-5F56-4841-AC64-1F9FB946BBB5@asu.edu>
Content-Type: text/plain; charset=“us-ascii”

I have a student who is interested in using some of the modeling tools available in GRASS extensions. These require some Python tools (e.g., scikit-learn) to be installed in her GRASS environments.

For me (on a Mac), I can just pip install -U scikit-learn from the GRASS terminal. But when she does this, the Windows terminal can’t find pip. This seems to be just a path problem but I don’t know how to troubleshoot it on Windows. She has installed Python via Anaconda and can use Python in GRASS via the Python console, but this does not seem to help in this case (conda can’t be found from the GRASS Windows terminal). Can someone point us to a guide of how to install Python packages into the GRASS environment on Windows and/or adjust the path so that the Windows terminal can access Python utilities?

Thanks
Michael


C. Michael Barton
Associate Director, School of Complex Adaptive Systems (https://scas.asu.edu<https://scas.asu.edu/>)
Professor, School of Human Evolution & Social Change (https://shesc.asu.edu)
Director, Center for Social Dynamics & Complexity (https://complexity.asu.edu)
Arizona State University
Tempe, AZ 85287-2701
USA

Executive Director, Open Modeling Foundation (https://openmodelingfoundation.github.io<https://openmodelingfoundation.github.io/>)
Director, Network for Computational Modeling in Social & Ecological Sciences (https://comses.net)

personal website: http://www.public.asu.edu/~cmbarton

-------------- next part --------------
An HTML attachment was scrubbed…
URL: <http://lists.osgeo.org/pipermail/grass-user/attachments/20241217/44ad7971/attachment-0001.htm>


Subject: Digest Footer


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


End of grass-user Digest, Vol 224, Issue 1


Hopefully someone smarter than me can figure this one out. I’ve been able to access GRASS GIS 8.4 from inside another python environment, but not the other way around. I don’t want to leave you empty-handed so here’s a workaround.

If she activates her conda environment and activates a python shell or program you can throw the following into an IPython session or other Python program.

“”"
import sys
import subprocess
sys.path.append(subprocess.check_output([“C:\Program Files\GRASS GIS 8.4\grass84.bat”, “–config”, “python_path”], text=True, shell=True).strip())
import grass.script as gs

Now you can add any other imports that you want.

“”"

Things get a little easier if she adds the directory "C:\Program Files\GRASS GIS 8.4" into her “Path” environment variable so she can execute “grass84.bat” or “grass84” from the terminal and you can replace the full path in the code above to “grass84”. You can also execute commands in a grass shell like you can on Linux or Mac from Powershell or the Command Prompt.

She can even use the new grass.jupyter interface to run grass modules inside a Jupyter Notebook.

On Tue, Dec 17, 2024 at 7:13 PM Gregory Power <gregorywpower@gmail.com> wrote:

I just want to make sure I’m understanding you properly, you’re trying to access conda environments from inside the grass shell? They may need to open up a Powershell prompt, type “where.exe conda” copy the path that command spits out into their “Path” environment variable—which they can do at the “system” level or “user” level.

On Tue, Dec 17, 2024 at 18:52 Michael Barton <Michael.Barton@asu.edu> wrote:

Thanks Gregory. Currently, our issue is making sure that relevant Python packages are accessible within an operating GRASS environment, which is distinct from a general Windows environment.

Michael


C. Michael Barton
Associate Director, School of Complex Adaptive Systems (https://scas.asu.edu)
Professor, School of Human Evolution & Social Change (https://shesc.asu.edu)
Director, Center for Social Dynamics & Complexity (https://complexity.asu.edu)
Arizona State University
Tempe, AZ 85287-2701
USA

Executive Director, Open Modeling Foundation (https://openmodelingfoundation.github.io)

Director, Network for Computational Modeling in Social & Ecological Sciences (https://comses.net)

personal website: http://www.public.asu.edu/~cmbarton

On Dec 17, 2024, at 4:34 PM, Gregory Power <gregorywpower@gmail.com> wrote:

Disregard the previous, it appears the grass conda-forge feedstock isn’t alive. Let me do some digging and get back to you.

On Tue, Dec 17, 2024 at 5:53 PM Gregory Power <gregorywpower@gmail.com> wrote:

Hey Michael & Vanessa,

Wrangling Python packages can be a bit tricky. Especially if you’re dealing with virtual environments. Installing packages through pip could cause your dependencies to conflict between projects. That being said, Anaconda’s conda does have its own pitfalls, especially if you’re part of an organization larger than 200 people that uses Anaconda’s channels (the conda-forge channel is exempt from this since it is community run).

Vanessa will have to create a python environment through conda or pixi and add grass/scikit-learn to the same environment. I’d recommend pixi instead of having to reconfigure conda to point to new channels. If you’re only able to work with conda, I’d recommend creating a new environment and putting both of those dependencies into their own project.

Here’s the instructions from the osgeo-forge grass-feedstock.

conda config --add channels conda-forge

If you want to install both packages into your ‘base’ environment on Anaconda. But I highly recommend you at least create a new environment and install your packages there.

conda install grass scikit-learn

With pixi:

pixi init
cd
pixi add python grass scikit-learn
pixi shell

Thank you,
Gregory

On Tue, Dec 17, 2024 at 3:01 PM <grass-user-request@lists.osgeo.org> wrote:

Send grass-user mailing list submissions to
grass-user@lists.osgeo.org

To subscribe or unsubscribe via the World Wide Web, visit
https://lists.osgeo.org/mailman/listinfo/grass-user
or, via email, send a message with subject or body ‘help’ to
grass-user-request@lists.osgeo.org

You can reach the person managing the list at
grass-user-owner@lists.osgeo.org

When replying, please edit your Subject line so it is more specific
than “Re: Contents of grass-user digest…”

Today’s Topics:

  1. Python in GRASS on Windows (Michael Barton)

Message: 1
Date: Tue, 17 Dec 2024 16:53:04 +0000
From: Michael Barton <Michael.Barton@asu.edu>
To: GRASS users <grass-user@lists.osgeo.org>, GRASS developers
<grass-dev@discourse.osgeo.org>
Cc: Vanessa Extrem <Vanessa.Extrem@uv.es>
Subject: [GRASS-user] Python in GRASS on Windows
Message-ID: <12319197-5F56-4841-AC64-1F9FB946BBB5@asu.edu>
Content-Type: text/plain; charset=“us-ascii”

I have a student who is interested in using some of the modeling tools available in GRASS extensions. These require some Python tools (e.g., scikit-learn) to be installed in her GRASS environments.

For me (on a Mac), I can just pip install -U scikit-learn from the GRASS terminal. But when she does this, the Windows terminal can’t find pip. This seems to be just a path problem but I don’t know how to troubleshoot it on Windows. She has installed Python via Anaconda and can use Python in GRASS via the Python console, but this does not seem to help in this case (conda can’t be found from the GRASS Windows terminal). Can someone point us to a guide of how to install Python packages into the GRASS environment on Windows and/or adjust the path so that the Windows terminal can access Python utilities?

Thanks
Michael


C. Michael Barton
Associate Director, School of Complex Adaptive Systems (https://scas.asu.edu<https://scas.asu.edu/>)
Professor, School of Human Evolution & Social Change (https://shesc.asu.edu)
Director, Center for Social Dynamics & Complexity (https://complexity.asu.edu)
Arizona State University
Tempe, AZ 85287-2701
USA

Executive Director, Open Modeling Foundation (https://openmodelingfoundation.github.io<https://openmodelingfoundation.github.io/>)
Director, Network for Computational Modeling in Social & Ecological Sciences (https://comses.net)

personal website: http://www.public.asu.edu/~cmbarton

-------------- next part --------------
An HTML attachment was scrubbed…
URL: <http://lists.osgeo.org/pipermail/grass-user/attachments/20241217/44ad7971/attachment-0001.htm>


Subject: Digest Footer


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


End of grass-user Digest, Vol 224, Issue 1


On Wed, Dec 18, 2024 at 5:46 AM Gregory Power via grass-user
<grass-user@lists.osgeo.org> wrote:

Hopefully someone smarter than me can figure this one out. I've been able to access GRASS GIS 8.4 from inside another python environment, but not the other way around. I don't want to leave you empty-handed so here's a workaround.

I didn't look into the details of this conversion but just to notify
about this recently updated approach:

https://github.com/OSGeo/grass/blob/main/docker/testdata/test_grass_session.py

Best
Markus