Opened 15 years ago

Closed 13 years ago

#96 closed defect (invalid)

"import grass.script as grass" in Python GRASS AddOns doesn't work

Reported by: aghisla Owned by: osgeo4w-dev@…
Priority: major Component: Package
Version: Keywords: grass addon python grass.script
Cc:

Description

I'm trying to run a Python AddOn in OSGeo4W GRASS. There are some problems in getting grass-python module work.

  1. Native install:
  • GRASS 6.4.0svn2
  • bundled Python
Welcome to GRASS 6.4.0svn (2009) 
Microsoft Windows XP [Versione 5.1.2600]
(C) Copyright 1985-2001 Microsoft Corp.

GRASS 6.4.0svn (spearfish60)> python C:\v.krige\v.krige.py
Traceback (most recent call last):
  File "C:\v.krige\v.krige.py", line 54, in <module>
    import grass.script as grass
ImportError: No module named script
  1. Modified install:
  • as above
  • python folder in C:\OSGeo4W\apps\grass\grass-6.4.0svn\etc\ substituted with the python folder in grass6_develbranch, rev 38064
GRASS 6.4.0svn (spearfish60)> python C:\v.krige\v.krige.py 
Traceback (most recent call last):
  File "C:\v.krige\v.krige.py", line 54, in <module>
    import grass.script as grass
ImportError: No module named grass.script

GRASS 6.4.0svn (spearfish60)> python 
Python 2.5.2 (r252:60911, Feb 21 2008, 13:11:45) [MSC v.1310 32 bit (Intel)] on
win32
>>> import core as grass 
>>> grass.run_command("g.list", type="vect")
----------------------------------------------
vector files available in mapset <PERMANENT>:
archsites       roads           t_9961_200      t_9961_500      t_roads_prime
...

so bundled Python can actually import the module, but not as grass.script. There's something I'm missing, but hope this report helps.

BTW, there is a similar ticket (#95) but about QGIS and not on the same issue, but also about grass module.

Change History (2)

comment:1 by aghisla, 15 years ago

In fact it is the same error I had when my compiled GRASS (6_develbranch) on Debian had a outdated python-grass library. Recompiling it using r38013 solved the problem.

I tried upgrading python/ and wxpython/ folders in C:\OSGeo4W\apps\grass\grass-6.4.0svn\etc but the error persists.

I'll try to compile a newer version of grass on Windows and give further feedback.

comment:2 by maphew, 13 years ago

Resolution: invalid
Status: newclosed

I'm closing this ticket as too old to apply to the current state of packages. Please feel free to re-open if it is indeed still a problem.

Note: See TracTickets for help on using tickets.