[GRASS-user] Problem accessing GRASS from GRASS from PostgreSQL9.1/PostGIS2.0 via pg-python or plpythonu

Mark Wynter mark at dimensionaledge.com
Thu Jul 19 05:36:41 PDT 2012


Thanks Andrew

> I suggest running a test script that reports sys.path to confirm that the actual Python module search path seen by the Postgres server's environment is as expected.


From the python console, logged in as posgres user....

postgres at ip-10-252-74-140:/home/ubuntu$ python -c 'import sys; print sys.version, sys.path'
2.7.3 (default, Apr 20 2012, 22:39:59) 
[GCC 4.6.3] ['', '/home/ubuntu', '/usr/local/grass-6.4.3svn/etc/python', '/usr/local/grass-6.4.3svn/etc/python/grass', '/usr/local/grass-6.4.3svn/etc/python/grass/script', '/usr/lib/python2.7', '/usr/lib/python2.7/plat-linux2', '/usr/lib/python2.7/lib-tk', '/usr/lib/python2.7/lib-old', '/usr/lib/python2.7/lib-dynload', '/usr/local/lib/python2.7/dist-packages', '/usr/lib/python2.7/dist-packages', '/usr/lib/pymodules/python2.7', '/usr/lib/python2.7/dist-packages/wx-2.8-gtk2-unicode']

From postgresql....

test=# CREATE FUNCTION pyversion() RETURNS text AS $$
test$# import sys
test$# return sys.version + '\n' + '\n'.join(sys.path)
test$# $$ LANGUAGE plpythonu;
CREATE FUNCTION

test=# select pyversion();
                      pyversion                       
------------------------------------------------------
 2.7.3 (default, Apr 20 2012, 23:04:22)              +
 [GCC 4.6.3]                                         +
 /usr/lib/python2.7                                  +
 /usr/lib/python2.7/plat-linux2                      +
 /usr/lib/python2.7/lib-tk                           +
 /usr/lib/python2.7/lib-old                          +
 /usr/lib/python2.7/lib-dynload                      +
 /usr/local/lib/python2.7/dist-packages              +
 /usr/lib/python2.7/dist-packages                    +
 /usr/lib/pymodules/python2.7                        +
 /usr/lib/python2.7/dist-packages/wx-2.8-gtk2-unicode
(1 row)

test=# CREATE OR REPLACE FUNCTION pgpython_test()
test-# RETURNS text LANGUAGE python AS
test-# $python$
test$# import sys
test$# def main():
test$#     return sys.version + '\n' + '\n'.join(sys.path)
test$# $python$;
CREATE FUNCTION

test=# select pgpython_test();
              pgpython_test              
-----------------------------------------
 3.2.3 (default, May  3 2012, 15:48:36) +
 [GCC 4.6.3]                            +
 /usr/lib/python3.2                     +
 /usr/lib/python3.2/plat-linux2         +
 /usr/lib/python3.2/lib-dynload         +
 /usr/local/lib/python3.2/dist-packages +
 /usr/lib/python3/dist-packages
(1 row)

OK, I've got two versions of python: 2.7 and 3.2...
Both python console and postgresql can see python 2.7 but plus it appears the grass environmental variables are not finding their way into the $pythonpath as seen by the postgresql server??????

Any suggestions?





More information about the grass-user mailing list