将grass.script导入PyDev时出现问题



我正在尝试在 Eclipse 中编写草脚本,并按照本页中概述的说明进行操作。我想我已经配置了所有内容,但是当我尝试导入 grass.script 时,我收到以下消息:

Traceback (most recent call last):
  File "/home/nesic/Desktop/grass_dev/Simulacije/test.py", line 6, in <module>
    import grass.script as grass
  File "/usr/lib/grass64/etc/python/grass/script/__init__.py", line 1, in <module>
    from core   import *
  File "/usr/lib/grass64/etc/python/grass/script/core.py", line 38, in <module>
    gettext.install('grasslibs', os.path.join(os.getenv("GISBASE"), 'locale'), unicode=True)
  File "/usr/local/lib/python2.6/posixpath.py", line 67, in join
    elif path == '' or path.endswith('/'):
AttributeError: 'NoneType' object has no attribute 'endswith'

我做错了什么?

os.getenv("GISBASE")很可能返回None,因为没有设置环境变量GISBASE。然后导致您所看到的AttributeError: 'NoneType' object has no attribute 'endswith'

尝试根据 http://grass.osgeo.org/grass70/manuals/variables.html 设置GISBASE

吉斯巴斯

directory where GRASS lives. This is set automatically by the startup script.

(顺便说一句,如果你还不知道,还有 gis.stackexchange.org)

最新更新