python and ubuntu's environment
Patrick Asselman
iceblink at seti.nl
Tue Jul 23 14:01:46 UTC 2013
On 2013-07-23 15:14, Tung Thanh wrote:
> Thank Patrick
>
> my python version is
>
> mycrt009:~$ python
> Python 2.6.8 (default, Apr 26 2013, 16:32:35)
> [GCC 4.7.2] on linux2
> Type "help", "copyright", "credits" or "license" for more
> information.
>
>>>>
>
> and Grass version is
>
>>>> import sys
>>>> print sys.path
> ['', '/usr/local/grass-6.4.3svn/scripts',
> '/usr/local/grass-6.4.3svn/etc/python', '/usr/lib/python2.6',
> '/usr/lib/python2.6/plat-linux2', '/usr/lib/python2.6/lib-tk',
> '/usr/lib/python2.6/lib-old', '/usr/lib/python2.6/lib-dynload',
> '/usr/local/lib/python2.6/dist-packages',
> '/usr/lib/python2.6/dist-packages']
>>>> python
>
> I tried import grass script, It is fine..example
>
> :~$ python
> Python 2.6.8 (default, Apr 26 2013, 16:32:35)
> [GCC 4.7.2] on linux2
> Type "help", "copyright", "credits" or "license" for more
> information.
>>>> import grass.script as g
>>>> g.run_command("g.list", flags="f", type="rast,vect")
> 0
>>>>
>
> BUt when I tried to call web service by Curl, It says "in
> <module>import grass.script as grassImportError: No module named
>> grass.script"
>
> And all of my folder It puted in new user (username) I create new
> username by $> adduser mywps
> and all the folder such as
> home -
> mywps
> tomcat (hosting my wps service)
> grass_python
> data
>
> I hope it is clear for you to see what my problem is
>
> Many thanks
>
> T.X.Tung
So your service is running under a different user called mywps.
Apparently that user does not have the grass.script in his sys.path.
I think you need to do some Googling on "Python module import path"...
Or do some debugging... have your script write back the sys.path and
working directory, see where that leads to.
Best regards,
Patrick Asselman
More information about the ubuntu-users
mailing list