[GRASS-dev] [GRASS GIS] #1619: v.krige won't load: ImportError: No module named globalvar

#1619: v.krige won't load: ImportError: No module named globalvar
---------------------+------------------------------------------------------
Reporter: momsen | Owner: grass-dev@…
     Type: defect | Status: new
Priority: normal | Milestone: 7.0.0
Component: Default | Version: svn-trunk
Keywords: krige | Platform: Linux
      Cpu: x86-64 |
---------------------+------------------------------------------------------
Hello, I have installed GRASS 7 this week, along with
gdal/geos/spgrass6/etc. I'm on a Debian system. R and many of the
dependencies came from Debian packages. But gdal and GRASS I installed
from source.

v.krige gives the following errors. R/spgrass6 does work, I used
readVECT6 and readRAST6 to load data into R.

Is there something else I should install/change on my side, or is this a
bug?

{{{
v.krige
Loading dependencies, please wait...
rgeos: (SVN revision 326)
  GEOS runtime version: 3.3.1-CAPI-1.7.1
  Polygon checking: TRUE
  WARNING! if you turn polygon checking off, and polygons are
  not valid in GEOS, you risk losing data as your R session may crash!
Loading required package: zoo
Attaching package: ‘zoo’
The following object(s) are masked from ‘package:base’:
     as.Date, as.Date.numeric
Loading required package: xts
GRASS GIS interface loaded with GRASS version: GRASS 7.0.svn (2012)
and location: spearfish70
Checking rgeos availability: TRUE
Traceback (most recent call last):
   File "/usr/local/grass-7.0.svn/scripts/v.krige", line 411,
in <module>
     main()
   File "/usr/local/grass-7.0.svn/scripts/v.krige", line 299,
in main
     import globalvar
ImportError: No module named globalvar
(Thu Mar 15 14:55:17 2012) Command finished (1 sec)
(Thu Mar 15 15:43:42 2012)
g.gisenv -n
LOCATION_NAME=spearfish70
GISDBASE=/home/emomsen/GRASSDATA
MAPSET=user1
GUI=wxpython
}}}

I tried loading the R package dependencies I knew about in R, that seemed
to be a common theme in previous v.krige errors. I think I have
everything installed.

{{{
> sessionInfo()
R version 2.14.1 (2011-12-22)
Platform: x86_64-pc-linux-gnu (64-bit)

locale:
  [1] LC_CTYPE=en_US.UTF-8 LC_NUMERIC=C
  [3] LC_TIME=en_US.UTF-8 LC_COLLATE=en_US.UTF-8
  [5] LC_MONETARY=en_US.UTF-8 LC_MESSAGES=en_US.UTF-8
  [7] LC_PAPER=C LC_NAME=C
  [9] LC_ADDRESS=C LC_TELEPHONE=C
[11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C

attached base packages:
[1] stats graphics grDevices utils datasets methods base

other attached packages:
  [1] maptools_0.8-14 lattice_0.20-0 foreign_0.8-49 automap_1.0-12
  [5] gstat_1.0-10 spacetime_0.6-0 rgeos_0.2-3 stringr_0.6
  [9] xts_0.8-2 zoo_1.7-7 spgrass6_0.7-9 XML_3.9-4
[13] sp_0.9-97

loaded via a namespace (and not attached):
[1] grid_2.14.1 plyr_1.7.1
}}}

Other dependencies:

{{{
emomsen@gis-dev-test:/usr/local/grass-7.0.svn/scripts$ aptitude search
rpy2
i python-rpy2 - Python interface
to the GNU R language and environment (ver
v python2.6-rpy2 -
v python2.7-rpy2 -

}}}

Anything I should normally be reporting? I checked the subversion number:

{{{
root@gis-dev-test:/opt/grass_trunk# svn info
Path: .
URL: https://svn.osgeo.org/grass/grass/trunk
Repository Root: https://svn.osgeo.org/grass
Repository UUID: 15284696-431f-4ddb-bdfa-cd5b030d7da7
Revision: 51063
Node Kind: directory
Schedule: normal
Last Changed Author: martinl
Last Changed Rev: 51060
Last Changed Date: 2012-03-14 17:13:32 -0500 (Wed, 14 Mar 2012)
}}}

Thanks for any help!

--
Ticket URL: <http://trac.osgeo.org/grass/ticket/1619&gt;
GRASS GIS <http://grass.osgeo.org>

#1619: v.krige won't load: ImportError: No module named globalvar
---------------------+------------------------------------------------------
Reporter: momsen | Owner: grass-dev@…
     Type: defect | Status: new
Priority: normal | Milestone: 7.0.0
Component: Default | Version: svn-trunk
Keywords: krige | Platform: Linux
      Cpu: x86-64 |
---------------------+------------------------------------------------------

Comment(by aghisla):

Hello momsen,

thanks for the well detailed report.

v.krige is not aware of last GUI reorganisations, so it can't load
properly, as stated by the traceback:

   ImportError: No module named globalvar

So far I didn't find the time to update the module. If you are willing to
help, let me know.

Moreover, the module should not require zoo and xts packages. I can't see
them as dependencies of the modules needed by v.krige, that are:
   rgeos, gstat, spgrass6, maptools

Can you load these packages in a R session?

Thanks for the feedback,
Anne

--
Ticket URL: <http://trac.osgeo.org/grass/ticket/1619#comment:1&gt;
GRASS GIS <http://grass.osgeo.org>

#1619: v.krige won't load: ImportError: No module named globalvar
---------------------+------------------------------------------------------
Reporter: momsen | Owner: grass-dev@…
     Type: defect | Status: new
Priority: normal | Milestone: 7.0.0
Component: Default | Version: svn-trunk
Keywords: krige | Platform: Linux
      Cpu: x86-64 |
---------------------+------------------------------------------------------

Comment(by momsen):

It is nice to hear I've finally gotten to the point where my installation
wasn't at fault. I have not yet updated/written code for any open source
projects, but want to learn. I have a presentation Tuesday, so if someone
can provide guidance I could look at it then. If you find time to make
the update before that, I'm sure there will be other things I can help
with later.

I'm late for leaving for the weekend, I'll be able to check more on zoo
and xts later. Both can be loaded directly in R as well, from memory zoo
was a dependency for one of the spgrass6 related packages. At least it
shows up each time I installed it!

-Eric

--
Ticket URL: <http://trac.osgeo.org/grass/ticket/1619#comment:2&gt;
GRASS GIS <http://grass.osgeo.org>

#1619: v.krige won't load: ImportError: No module named globalvar
---------------------+------------------------------------------------------
Reporter: momsen | Owner: grass-dev@…
     Type: defect | Status: new
Priority: normal | Milestone: 7.0.0
Component: Default | Version: svn-trunk
Keywords: krige | Platform: Linux
      Cpu: x86-64 |
---------------------+------------------------------------------------------

Comment(by momsen):

I am able to load rgeos, gstat, spgrass6, and maptools in a R session.

I found where zoo and xts came from:

automap is optional (provides automatic variogram fit) for v.krige.
automap depends on gstat, which depends on spacetime, which depends on zoo
and xts.

-Eric

--
Ticket URL: <http://trac.osgeo.org/grass/ticket/1619#comment:3&gt;
GRASS GIS <http://grass.osgeo.org>

#1619: v.krige won't load: ImportError: No module named globalvar
---------------------+------------------------------------------------------
Reporter: momsen | Owner: grass-dev@…
     Type: defect | Status: new
Priority: normal | Milestone: 7.0.0
Component: Default | Version: svn-trunk
Keywords: krige | Platform: Linux
      Cpu: x86-64 |
---------------------+------------------------------------------------------
Changes (by neteler):

* cc: aghisla (added)

Comment:

Startup problems fixed in r53127.

Remaining issue: creating the variogram leads to
{{{
Traceback (most recent call last):
   File "/home/neteler/grass70/dist.x86_64-unknown-linux-
gnu/etc/gui/wxpython/scripts/vkrige.py", line 444, in OnPlotButton
     if globals()["InputData"] is None:
KeyError: 'InputData'
Traceback (most recent call last):
   File "/home/neteler/grass70/dist.x86_64-unknown-linux-
gnu/etc/gui/wxpython/scripts/vkrige.py", line 444, in OnPlotButton
     if globals()["InputData"] is None:
KeyError: 'InputData'
Traceback (most recent call last):
   File "/home/neteler/grass70/dist.x86_64-unknown-linux-
gnu/etc/gui/wxpython/scripts/vkrige.py", line 256, in OnRunButton
     self.goutput.RunCmd(command, switchPage = True)
   File "/home/neteler/grass70/dist.x86_64-unknown-linux-
gnu/etc/gui/wxpython/gui_core/goutput.py", line 604, in RunCmd
     self._notebook.SetSelectionByName('output')
AttributeError: 'FlatNotebook' object has no attribute
'SetSelectionByName'
}}}

--
Ticket URL: <https://trac.osgeo.org/grass/ticket/1619#comment:4&gt;
GRASS GIS <http://grass.osgeo.org>

#1619: v.krige won't load: ImportError: No module named globalvar
---------------------+------------------------------------------------------
Reporter: momsen | Owner: grass-dev@…
     Type: defect | Status: new
Priority: normal | Milestone: 7.0.0
Component: Default | Version: svn-trunk
Keywords: krige | Platform: Linux
      Cpu: x86-64 |
---------------------+------------------------------------------------------

Comment(by annakrat):

I can fix the FlatNotebook part of error (probably tomorrow, I must first
download some packages to be able to test it).

Anna

--
Ticket URL: <https://trac.osgeo.org/grass/ticket/1619#comment:5&gt;
GRASS GIS <http://grass.osgeo.org>

#1619: v.krige won't load: ImportError: No module named globalvar
---------------------+------------------------------------------------------
Reporter: momsen | Owner: grass-dev@…
     Type: defect | Status: new
Priority: normal | Milestone: 7.0.0
Component: Default | Version: svn-trunk
Keywords: krige | Platform: Linux
      Cpu: x86-64 |
---------------------+------------------------------------------------------

Comment(by annakrat):

Replying to [comment:5 annakrat]:
> I can fix the FlatNotebook part of error (probably tomorrow, I must
first download some packages to be able to test it).

After installation of needed packages I get this error:

{{{
GRASS 7.0.svn (spearfish60):/usr/local/src/trunk > v.krige
Loading dependencies, please wait...
rgeos: (SVN revision 348)
  GEOS runtime version: 3.3.3-CAPI-1.7.4
  Polygon checking: TRUE

Loading required package: zoo

Attaching package: ‘zoo’

The following object(s) are masked from ‘package:base’:

     as.Date, as.Date.numeric

Loading required package: xts
GRASS GIS interface loaded with GRASS version: GRASS 7.0.svn (2012)
and location: spearfish60
Checking rgeos availability: TRUE
Loading required package: automap
Traceback (most recent call last):
   File "/usr/local/src/trunk/dist.i686-pc-linux-gnu/scripts/v.krige", line
414, in <module>
     main()
   File "/usr/local/src/trunk/dist.i686-pc-linux-gnu/scripts/v.krige", line
312, in main
     controller = controller)
   File "/usr/local/src/trunk/dist.i686-pc-linux-
gnu/etc/gui/wxpython/scripts/vkrige.py", line 269, in __init__
     self.Panel = KrigingPanel(self, Rinstance, controller)
   File "/usr/local/src/trunk/dist.i686-pc-linux-
gnu/etc/gui/wxpython/scripts/vkrige.py", line 98, in __init__
     self.CreatePage(package = Rpackage, Rinstance = Rinstance, controller
= controller)
   File "/usr/local/src/trunk/dist.i686-pc-linux-
gnu/etc/gui/wxpython/scripts/vkrige.py", line 175, in CreatePage
     controller = controller)))
   File "/usr/local/src/trunk/dist.i686-pc-linux-
gnu/etc/gui/wxpython/scripts/vkrige.py", line 394, in __init__
     ModelFactor = robjects.r.vgm().rx('long')
AttributeError: 'RDataFrame' object has no attribute 'rx'
}}}
I have no idea what rx is or how too fix this.

Anna

--
Ticket URL: <https://trac.osgeo.org/grass/ticket/1619#comment:6&gt;
GRASS GIS <http://grass.osgeo.org>

#1619: v.krige won't load: ImportError: No module named globalvar
---------------------+------------------------------------------------------
Reporter: momsen | Owner: grass-dev@…
     Type: defect | Status: new
Priority: normal | Milestone: 7.0.0
Component: Default | Version: svn-trunk
Keywords: krige | Platform: Linux
      Cpu: x86-64 |
---------------------+------------------------------------------------------

Comment(by annakrat):

The problem with notebook should be fixed in r53148.
Anna

--
Ticket URL: <https://trac.osgeo.org/grass/ticket/1619#comment:7&gt;
GRASS GIS <http://grass.osgeo.org>

#1619: v.krige won't load: ImportError: No module named globalvar
---------------------+------------------------------------------------------
Reporter: momsen | Owner: grass-dev@…
     Type: defect | Status: new
Priority: normal | Milestone: 7.0.0
Component: Default | Version: svn-trunk
Keywords: krige | Platform: Linux
      Cpu: x86-64 |
---------------------+------------------------------------------------------

Comment(by neteler):

One more fix done in r53149.

--
Ticket URL: <https://trac.osgeo.org/grass/ticket/1619#comment:8&gt;
GRASS GIS <http://grass.osgeo.org>

#1619: v.krige won't load: ImportError: No module named globalvar
---------------------+------------------------------------------------------
Reporter: momsen | Owner: grass-dev@…
     Type: defect | Status: new
Priority: normal | Milestone: 7.0.0
Component: Default | Version: svn-trunk
Keywords: krige | Platform: Linux
      Cpu: x86-64 |
---------------------+------------------------------------------------------

Comment(by neteler):

For now v.krige is commented out in the parent Makefile, see r53194.

--
Ticket URL: <http://trac.osgeo.org/grass/ticket/1619#comment:9&gt;
GRASS GIS <http://grass.osgeo.org>

#1619: v.krige won't load: ImportError: No module named globalvar
---------------------+------------------------------------------------------
Reporter: momsen | Owner: grass-dev@…
     Type: defect | Status: new
Priority: normal | Milestone: 7.0.0
Component: Python | Version: svn-trunk
Keywords: v.krige | Platform: Linux
      Cpu: x86-64 |
---------------------+------------------------------------------------------
Changes (by hamish):

  * keywords: krige => v.krige
  * component: Default => Python

Comment:

Hi,

current status in trunk, starting from the command line:

{{{
(loading the R stuff works for me)
...
Traceback (most recent call last):
   File "/home/hamish/src/grass/svn/trunk/dist.x86_64-unknown-linux-
gnu/scripts/v.krige", line 412, in <module>
     main()
   File "/home/hamish/src/grass/svn/trunk/dist.x86_64-unknown-linux-
gnu/scripts/v.krige", line 310, in main
     controller = controller)
   File "/home/hamish/src/grass/svn/trunk/dist.x86_64-unknown-linux-
gnu/etc/gui/wxpython/scripts/vkrige.py", line 289, in __init__
     self.Panel = KrigingPanel(self, Rinstance, controller)
   File "/home/hamish/src/grass/svn/trunk/dist.x86_64-unknown-linux-
gnu/etc/gui/wxpython/scripts/vkrige.py", line 86, in __init__
     self.InputDataColumn.SetSelection(0)
AttributeError: 'ColumnSelect' object has no attribute 'SetSelection'
}}}

not sure how to fix that; the same works in devbr6. (v.krige now updated
in devbr6 to reflect recent wxgui dir layout changes & starts up ok there)

If I comment out the `self.InputDataColumn.SetSelection(0)` line the
v.krige GUI starts in trunk, so it isn't too badly broken.

Hamish

--
Ticket URL: <https://trac.osgeo.org/grass/ticket/1619#comment:10&gt;
GRASS GIS <http://grass.osgeo.org>

#1619: v.krige won't load: ImportError: No module named globalvar
---------------------+------------------------------------------------------
Reporter: momsen | Owner: grass-dev@…
     Type: defect | Status: new
Priority: normal | Milestone: 7.0.0
Component: Python | Version: svn-trunk
Keywords: v.krige | Platform: Linux
      Cpu: x86-64 |
---------------------+------------------------------------------------------

Comment(by annakrat):

Replying to [comment:10 hamish]:
> Hi,
>
> current status in trunk, starting from the command line:
>
> {{{
> (loading the R stuff works for me)
> ...
> Traceback (most recent call last):
> File "/home/hamish/src/grass/svn/trunk/dist.x86_64-unknown-linux-
gnu/scripts/v.krige", line 412, in <module>
> main()
> File "/home/hamish/src/grass/svn/trunk/dist.x86_64-unknown-linux-
gnu/scripts/v.krige", line 310, in main
> controller = controller)
> File "/home/hamish/src/grass/svn/trunk/dist.x86_64-unknown-linux-
gnu/etc/gui/wxpython/scripts/vkrige.py", line 289, in __init__
> self.Panel = KrigingPanel(self, Rinstance, controller)
> File "/home/hamish/src/grass/svn/trunk/dist.x86_64-unknown-linux-
gnu/etc/gui/wxpython/scripts/vkrige.py", line 86, in __init__
> self.InputDataColumn.SetSelection(0)
> AttributeError: 'ColumnSelect' object has no attribute 'SetSelection'
> }}}
>
> not sure how to fix that; the same works in devbr6. (v.krige now updated
in devbr6 to reflect recent wxgui dir layout changes & starts up ok there)
>
> If I comment out the `self.InputDataColumn.SetSelection(0)` line the
v.krige GUI starts in trunk, so it isn't too badly broken.

right, I removed it in r56920.

>
>
> Hamish

--
Ticket URL: <https://trac.osgeo.org/grass/ticket/1619#comment:11&gt;
GRASS GIS <http://grass.osgeo.org>

#1619: v.krige won't load: ImportError: No module named globalvar
---------------------+------------------------------------------------------
Reporter: momsen | Owner: grass-dev@…
     Type: defect | Status: new
Priority: normal | Milestone: 7.0.0
Component: Python | Version: svn-trunk
Keywords: v.krige | Platform: Linux
      Cpu: x86-64 |
---------------------+------------------------------------------------------

Comment(by hamish):

Replying to [comment:11 annakrat]:
> Replying to [comment:10 hamish]:
> > not sure how to fix that; the same works in devbr6.
...
> > If I comment out the `self.InputDataColumn.SetSelection(0)` line the
> > v.krige GUI starts in trunk, so it isn't too badly broken.
>
> right, I removed it in r56920.

I guess that's one way of fixing it :slight_smile: but there are a couple more like
it.
what do they do?

{{{
wxpython/scripts/vkrige.py", line 212, in OnInputDataChanged
     self.InputDataColumn.SetSelection(0)
AttributeError: 'ColumnSelect' object has no attribute 'SetSelection'
}}}

and after commenting that out ...

{{{
wxpython/scripts/vkrige.py", line 213, in OnInputDataChanged
     self.RunButton.Enable(self.InputDataColumn.GetSelection() is not -1)
AttributeError: 'ColumnSelect' object has no attribute 'GetSelection'
}}}

but then the [Plot/refresh variogram] button never lights up, nor the
[Run] button, and the suggested output map names don't get filled in.

> > (v.krige now updated in devbr6 to reflect recent wxgui dir layout
> > changes & starts up ok there)

still a couple tracebacks there re. `'FlatNotebook' object has no
attribute 'SetSelectionByName'` and `if globals()["InputData"] is None:
... KeyError: 'InputData'`.
see yesterday's comments in #1196.

thanks,
Hamish

--
Ticket URL: <https://trac.osgeo.org/grass/ticket/1619#comment:12&gt;
GRASS GIS <http://grass.osgeo.org>

#1619: v.krige won't load: ImportError: No module named globalvar
---------------------+------------------------------------------------------
Reporter: momsen | Owner: grass-dev@…
     Type: defect | Status: new
Priority: normal | Milestone: 7.0.0
Component: Python | Version: svn-trunk
Keywords: v.krige | Platform: Linux
      Cpu: x86-64 |
---------------------+------------------------------------------------------

Comment(by annakrat):

Replying to [comment:12 hamish]:

>
> but then the [Plot/refresh variogram] button never lights up, nor the
[Run] button, and the suggested output map names don't get filled in.

another fix r56924

>
>
> > > (v.krige now updated in devbr6 to reflect recent wxgui dir layout
> > > changes & starts up ok there)
>
> still a couple tracebacks there re. `'FlatNotebook' object has no
attribute 'SetSelectionByName'` and `if globals()["InputData"] is None:
... KeyError: 'InputData'`.
> see yesterday's comments in #1196.
>
>
> thanks,
> Hamish

--
Ticket URL: <https://trac.osgeo.org/grass/ticket/1619#comment:13&gt;
GRASS GIS <http://grass.osgeo.org>

#1619: v.krige won't load: ImportError: No module named globalvar
---------------------+------------------------------------------------------
Reporter: momsen | Owner: grass-dev@…
     Type: defect | Status: new
Priority: normal | Milestone: 7.0.0
Component: Python | Version: svn-trunk
Keywords: v.krige | Platform: Linux
      Cpu: x86-64 |
---------------------+------------------------------------------------------

Comment(by hamish):

Replying to [comment:13 annakrat]:
> another fix r56924

great, that fixes the two greyed out buttons and the output map name
suggestions are back.

when I press [Plot/refresh variogram] I get the same KeyError: 'InputData'
traceback as mentioned for devbr6, I tried adding it as "global InputData"
the the outer scripts/v.krige.py function which calls the controller, but
it still wasn't being exported to the list of globals read by
wxpython/scripts/vkrige.py. (maybe I did it wrong though)

when I press [Run] I got another traceback, but fixed that in r56925. Now
it runs in trunk from the GUI with reasonable looking results! (default
params, if I start messing with the fitting I run into other problems, and
some of the progress output is a bit garbled, but one step at a time.)

I notice it didn't pick up 'cat' as a numeric column since the
OnInputMapChanged() function in wx/vkrige.py has `excludeKey = True`. I'm
not sure how often the key column will be also used as a data column, but
if nothing else it's useful for testing, so for now I've re-enabled it in
r56926.
(* in testing spearfish's arch points using the cat column as the input I
notice one stray bad cell value (-2.27374e-13) in the results)

thanks,
Hamish

--
Ticket URL: <https://trac.osgeo.org/grass/ticket/1619#comment:14&gt;
GRASS GIS <http://grass.osgeo.org>

#1619: v.krige won't load: ImportError: No module named globalvar
---------------------+------------------------------------------------------
  Reporter: momsen | Owner: grass-dev@…
      Type: defect | Status: closed
  Priority: normal | Milestone: 7.0.0
Component: Python | Version: svn-trunk
Resolution: fixed | Keywords: v.krige
  Platform: Linux | Cpu: x86-64
---------------------+------------------------------------------------------
Changes (by aghisla):

  * status: new => closed
  * resolution: => fixed

Comment:

Hello all from GRASS Community Sprint in Prague!

v.krige is now fixed in trunk. I moved the global variables into
Controller class, and store them as attributes.

Testing is welcome!

I close this ticket and welcome you to open new ones with a proper title -
this one is getting a bit too crowded.

Thanks!
Anne

--
Ticket URL: <http://trac.osgeo.org/grass/ticket/1619#comment:15&gt;
GRASS GIS <http://grass.osgeo.org>