我正在尝试在Eclipse中编写草脚本,并按照this页面中的说明进行操作。我想我已经配置了所有内容,但是当我尝试导入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'
我做错了什么?
答案 0 :(得分:0)
os.getenv("GISBASE")
最有可能返回None
,因为未设置envorinment变量GISBASE
。然后会导致您看到的AttributeError: 'NoneType' object has no attribute 'endswith'
。
尝试根据http://grass.osgeo.org/grass70/manuals/variables.html设置GISBASE
:
GISBASE
directory where GRASS lives. This is set automatically by the startup script.
(顺便说一句,如果你还不知道,那还有gis.stackexchange.org)