[GRASS-dev] [GRASS GIS] #2424: PyGRASS does not work when GRASS is invoked from outside

#2424: PyGRASS does not work when GRASS is invoked from outside
-------------------------+-------------------------------------------------
  Reporter: wenzeslaus | Owner: grass-dev@…
      Type: defect | Status: new
  Priority: normal | Milestone: 7.1.0
Component: Python | Version: svn-trunk
  ctypes | Keywords: installation, pygrass, temporal,
Resolution: | scripts
       CPU: | Platform: MSWindows 8
  Unspecified |
-------------------------+-------------------------------------------------
Changes (by wenzeslaus):

* milestone: 7.0.0 => 7.1.0

Comment:

More general but related:

We may want to follow QGIS 3.0 ticket ''PyQGIS bootstrap is complicated''
which suggests adding QGIS Python packages to standard Python packages
path to avoid setting `PYTHONPATH` and perhaps other things:

https://github.com/qgis/qgis3.0_api/issues/9

Also note that now besides the
[https://grasswiki.osgeo.org/wiki/Working_with_GRASS_without_starting_it_explicitly
wiki page], we have also a pretty good
[https://grass.osgeo.org/grass70/manuals/libpython/script.html#module-
script.setup documentation] of the start process.

Additionally, besides the way suggested by [comment:1 Markus]:

{{{
export LD_LIBRARY_PATH=$(grass70 --config path)/lib
python python_script_with_pygrass_or_ctypes.py
}}}

we have now in trunk (after #2579):

{{{
grass ~/grassdata/nc_spm/test/ --exec
python_script_with_pygrass_or_ctypes.py
}}}

which ensures that the scripts runs in exactly same environment as if it
would be executed in GRASS GIS session.

--
Ticket URL: <https://trac.osgeo.org/grass/ticket/2424#comment:6&gt;
GRASS GIS <https://grass.osgeo.org>