2

I am trying to get started with GRASS scripting using Python and I figured that I would use Ipython notebooks, since I'm familiar with them. I follow this tutorial on youtube, but Python crashes when I try to start Ipython notebook in the grass command window (see in video at around 10 minutes). The error message is:

Fatal Python error: Py_Initialize: unable to load the file system codec

Possible clue: I use Python 3.5 in my notebooks, while GRASS apparently uses Python 2.7.

Johan
  • 406
  • 6
  • 20

1 Answers1

1

The best way how to do is to start ipython notebook command from the system command console (terminal) which is already running GRASS GIS session (the one with GRASS GIS written in ASCII characters) as described in the related tutorial. This will not work well from the Command Console in GUI (which is mostly meant for executing GRASS GIS modules). As far as I understand, you are already doing this the right way.

You are right about GRASS GIS currently supporting Python 2.7 and not Python 3. I don't think it is possible, both generally and in this case, to mix Python 2.7 with Python 3.x in this way. Using IPython for Python 2.7 is the way to go. It depends how GRASS GIS and IPython are installed on your system, but GRASS GIS from Linux distro packages will be configured to use the right Python and installing IPython for Python version 2 is likely just a matter of installing the right package (ipython-notebook and ipython3-notebook in my case).

The development version of GRASS GIS (trunk) contains some experimental support for Python 3 (not meant for learning but meant for further developement). You need to configure GRASS GIS to run with Python 3 first. Feel free to test it and improve it and write how far you get to the grass-dev mailing list or in case of patch or a particular error submit a ticket.

wenzeslaus
  • 667
  • 6
  • 13