0

I am trying to use the recently developed grass-session package inside Spyder in Linux Mint with GRASS 7.4.3 installed with a aim to do some geoprocessing without starting GRASS explicitly.

I installed grass-session by pip install grass-session under LinuxMint Cinnamon. My Spyder is under Miniconda3 but grass-session is not available in conda repos.

Here is my script that I am trying to run inside Spyder v3.2.6

mygisdb = '/tmp/grassdata'
mylocation = 'world'
mymapset = 'user'

import os, sys, subprocess

# ensuring the GRASSBIN is in the path and starting the GRASS GIS session
os.system('grass --config path')
os.system("export GRASSBIN=grass74")
from grass_session import Session

But when I run the last line trying to import grass-session, it gives me ImportError: No module named grass_session

Running Spyder from GRASS Shell gives me access to basic modules like grass.script and so on, but as I mentioned, I want to do it without starting GRASS each time. Any thoughts?

  • Running the GRASS GIS Shell sets the PYTHONPATH properly. In your case above it is either not set or lacking the path to site-packages/grass-session/ (whereever it is on your system). Please check (in Python, before starting the GRASS GIS session) how it is set and edit your posting accordingly. – markusN Jan 9 at 21:19

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.