Hi everyone!
I am trying to wrote a Python Script for importing CSV files to GRASS GIS without start GRASS. But I am getting a OSError:
import grass.script as g
g.run_command(“db.in.ogr”, dsn=“table.csv”, output=“test”)
Traceback (most recent call last):
File “”, line 1, in
File “/usr/lib/grass64/etc/python/grass/script/core.py”, line 189, in run_command
ps = start_command(*args, **kwargs)
File “/usr/lib/grass64/etc/python/grass/script/core.py”, line 177, in start_command
return Popen(args, **popts)
File “/usr/lib/grass64/etc/python/grass/script/core.py”, line 56, in init
startupinfo, creationflags)
File “/usr/lib/python2.7/subprocess.py”, line 679, in init
errread, errwrite)
File “/usr/lib/python2.7/subprocess.py”, line 1249, in _execute_child
raise child_exception
OSError: [Errno 2] No such file or directory
I attached a IPython Notebook example (print version https://dl.dropbox.com/u/473460/import_table_test.html). The command works fine in GRASS console, GRASS Python console and the script executed inside GRASS.
Any help?
(attachments)
import_table.ipynb (8.39 KB)
···
–
Andrés Silva
On Thu, Aug 30, 2012 at 6:31 PM, Andrés Silva <andres.silva.m@gmail.com> wrote:
Hi everyone!
I am trying to wrote a Python Script for importing CSV files to GRASS GIS
without start GRASS.
But I am getting a OSError:
Did you check this section about setting the right variables?
http://grass.osgeo.org/wiki/GRASS_and_Python#Creating_Python_scripts_that_call_GRASS_functionality_from_outside
best,
Markus
Thanks! It's works! I have wrong the PATH variable defined. This are my definitions in .bashrc:
export GISBASE="/usr/lib/grass64"
#export PATH="$PATH:$GISBASE/bin:$GISBASE/script:$GISBASE/lib" # wrong!!!
export PATH="$PATH:$GISBASE/bin:$GISBASE/scripts"
export PYTHONPATH="${PYTHONPATH}:$GISBASE/etc/python/"
export PYTHONPATH="${PYTHONPATH}:$GISBASE/etc/python/grass"
export PYTHONPATH="${PYTHONPATH}:$GISBASE/etc/python/grass/script"
export LD_LIBRARY_PATH="$LD_LIBRARY_PATH:$GISBASE/lib"
export GIS_LOCK=$$
export GISRC="$HOME/.grassrc6"
*Andrés Silva
*
On 30/08/12 14:13, Markus Neteler wrote:
On Thu, Aug 30, 2012 at 6:31 PM, Andrés Silva<andres.silva.m@gmail.com> wrote:
Hi everyone!
I am trying to wrote a Python Script for importing CSV files to GRASS GIS
without start GRASS.
But I am getting a OSError:
Did you check this section about setting the right variables?
http://grass.osgeo.org/wiki/GRASS_and_Python#Creating_Python_scripts_that_call_GRASS_functionality_from_outside
best,
Markus