Opened 12 years ago

Closed 11 years ago

#1496 closed defect (fixed)

GRASS 7 nightly build: Python script commands not shown from GUI (missing Python collections module)

Reported by: giohappy Owned by: martinl
Priority: blocker Milestone: 7.0.0
Component: wxGUI Version: unspecified
Keywords: python scripts Cc: martinl
CPU: Unspecified Platform: MSWindows 7

Description

I'm evaluating the python scripting system, and I've found that on my Windows 7 machine no windows are opened inside the GUI for whatevere script. E.g. v.report, v.db.join, etc. don't show up. The problem seems due to "collections" python module missing from the bundled python.

GRASS 7.0.svn> Traceback (most recent call last):

File "C:\Program Files\GRASS 7.0.SVN\etc\gui\wxpython\wxgui.py", line 547, in

OnMenuCmd

menuform.GUI(parent = self).ParseCommand(cmd)

File "C:\Program Files\GRASS 7.0.SVN\etc\gui\wxpython\gui_modules\menuform.py"

, line 1903, in ParseCommand

blackList = _blackList)

File "C:\Program Files\GRASS 7.0.SVN\etc\python\grass\script\task.py", line 45

1, in parse_interface

tree = etree.fromstring(get_interface_description(name))

File "C:\Program Files\GRASS 7.0.SVN\etc\python\grass\script\task.py", line 43

8, in get_interface_description

"\n\nDetails: %(det)s") % { 'cmd': cmd, 'det' : decode(cmderr) }

grass.script.core.ScriptError: u'Unable to fetch interface description for command \'v.report\'. Details: Traceback (most recent call last):

File "C:
Program Files
GRASS 7.0.SVN
scripts
v.report.py", line 47, in <module>\r\nimport grass.script as grass\r\n File "C:
Program Files
GRASS 7.0.SVN
etc
python
grass
script
init.py", line 1, in <module> from core import * File "C:
Program Files
GRASS 7.0.SVN
etc
python
grass
script
core.py", line 31, in <module> import subprocess File "C:
Program Files
GRASS 7.0.SVN
Python25
lib
subprocess.py", line 376, in <module> import threading File "C:
Program Files
GRASS 7.0.SVN
Python25
lib
threading.py", line 13, in <module> from collections import deque ImportError: No module named collections

Attachments (1)

python-windows.diff (3.3 KB ) - added by martinl 12 years ago.

Download all attachments as: .zip

Change History (11)

comment:1 by martinl, 12 years ago

Priority: criticalblocker

Known problem, unfortunately not solved yet. At least I have similar problem on my machine. See

You have probably more Python versions installed on your computer. When getting interface description Popen calls module again probably with different version of Python rather then by GRASS_PYTHON.

Martin

comment:2 by giohappy, 12 years ago

Too bad... So it's something with the command invocation system, because from CLI the collections builtin module is correctly loade, and from sys.path I can see that no mangling happens between different python versions on my pc. Does it mean that the GUI (or whatelse for it) doesn't correctly set the right paths for the embedded Python? Does it simply call a python module with the default system Python interpreter?

comment:3 by martinl, 12 years ago

Cc: martinl added
Keywords: python scripts added

Please try the attached patch or daily build (1). The source of problems is a mismatch of Python versions. You are launching Python scripts with Python version distributed within OSGeo4W framework. To get interface description the same script (module) is launched again source:grass/trunk/lib/python/task.py#L439 but with Python version defined by OS. The workaround applied in the patch

os.chdir(os.path.join(os.getenv('GISBASE'), 'scripts'))
cmdout, cmderr = Popen([sys.executable, cmd, '--interface-description'], stdout = PIPE,
                       stderr = PIPE).communicate()

(1) http://wingrass.fsv.cvut.cz/grass70/WinGRASS-7.0.SVN-r49498-1-Setup.exe

by martinl, 12 years ago

Attachment: python-windows.diff added

in reply to:  3 ; comment:4 by martinl, 12 years ago

Replying to martinl:

Please try the attached patch or daily build (1). The source of problems is a

patch applied in r49596, I hope that some better way how to fix this issue will be found in the future.

in reply to:  4 comment:5 by martinl, 12 years ago

Replying to martinl:

Replying to martinl:

Please try the attached patch or daily build (1). The source of problems is a

patch applied in r49596, I hope that some better way how to fix this issue will be found in the future.

r49565 is correct revision

comment:6 by giohappy, 12 years ago

thx Marting, I'll test it ASAP

comment:7 by giohappy, 12 years ago

I've just installed WinGRASS-7.0.SVN-r49586-1-Setup.exe nightly build, which includes r49565 fix, but trying to run v.report causes the following crash:

Traceback (most recent call last):
  File "C:\Program Files\GRASS
7.0.SVN\etc\gui\wxpython\wxgui.py", line 531, in OnMenuCmd

GUI(parent = self).ParseCommand(cmd)
  File "C:\Program Files\GRASS
7.0.SVN\etc\gui\wxpython\gui_core\forms.py", line 1967, in
ParseCommand

blackList = _blackList)
  File "c:/osgeo4w/usr/src/grass_trunk/dist.i686-pc-
mingw32/etc/python/grass/script/task.py", line 465, in
parse_interface
  File
"c:\OSGeo4W\apps\Python25\lib\xml\etree\ElementTree.py",
line 964, in XML

return parser.close()
  File
"c:\OSGeo4W\apps\Python25\lib\xml\etree\ElementTree.py",
line 1254, in close

self._parser.Parse("", 1) # end of data
xml.parsers.expat
.
ExpatError
:
no element found: line 1, column 0

in reply to:  7 ; comment:8 by martinl, 12 years ago

Replying to giohappy:

I've just installed WinGRASS-7.0.SVN-r49586-1-Setup.exe nightly build, which includes r49565 fix, but trying to run v.report causes

could you please try more recent version from wingrass.fsv.cvut.cz/grass70?

in reply to:  8 comment:9 by martinl, 11 years ago

Replying to martinl:

Replying to giohappy:

I've just installed WinGRASS-7.0.SVN-r49586-1-Setup.exe nightly build, which includes r49565 fix, but trying to run v.report causes

could you please try more recent version from wingrass.fsv.cvut.cz/grass70?

ping. ML

comment:10 by martinl, 11 years ago

Resolution: fixed
Status: newclosed

No answer almost one year. This issue should be already fixed. Closing, please re-open if needed.

Note: See TracTickets for help on using tickets.