Hi, i am new to Pydev. I have Eclipse 3.4.1, Pydev 126.96.36.19936 and Python 2.5+
I have a very simple program which uses GRASS GIS as follows:
The grass.gisenv code is executed (calls g.gisenv in GRASS which extracts the environment variables) but I cannot trace it to pinpoint the problem because source code does not show up.
The debugger does not show the source of grass.py when debugging through it, although it is listed among the external source libraries in the Project properties.
The print statement prints nothing even though GISRC is listed among the environment variables both in the Eclipse debug configuration and in the Window Preferences.
How can i make the source code of grass.py to show up when debugging it,?
PS g.gisenv runs OK when run in GRASS
Sorry, forgot to mention I am using WinXP
Are you sure that's python code and not a c++ compiled function?
You can check if the environment variables are correct from:
for key, value in os.environ.items(): print key, value
If it's not there, then it's a problem in Pydev...
Thank you Fabio and apologies for the delay in answering, I have been away for a while.
The good news is that the variable shows up, therefore the problem is not Pydev. I have since re-installed Eclipse, Python2.6 and Pydev and now all is well and debugging works as expected.
However I have also now tested WinXP and Ubuntu 9.04(with Grass (6.4.rc4), Eclipse (3.4.2) and Pydev 1.4.5., Python 2.6 with uneven results.
Using Eclipse to run or debug this short Python program:
env = grass.gisenv()
res = grass.find_file(vectorname,type,mapset)
rem = grass.read_command('g.remove', vect=vectorname)
behaves faultlessly under WinXP but when run under Ubuntu although it runs without errors, only the first two commands are actually executed and produce output, the g.remove appears to be executed (i.e. no error is given) but results in no removal and no output.
The same source program runs correctly when executed in Ubuntu as a normal python script from the Grass terminal (hence GRASS is not at fault).
Given that the first two commands only read data and the third has to write, could this be a permissions error, (although no error is given)?
Any help you can give would be greatly appreciated.
Ok, it executes as a normal python script from the Grass terminal, but does it run from a shell properly (e.g.: if you start the command from /bin/sh python your_script.py, does it work... it could be that it only works from the grass terminal... or did I misunderstand something here?)
Sorry Fabio, simultaneously with your reply I completed a detailed comparison between the Win environment and the Ubuntu one, and found that one critical environment variable was not defined in my Ubuntu Eclipse run configuration. Once I defined it, all worked correctly.
My apologies again for the false alarm and thank you for your prompt reply.
All the best
Sign up for the SourceForge newsletter:
You seem to have CSS turned off.
Please don't fill out this field.