python scripting for arcgis_Python ImportError: No module named arcgisscripting

在做《ArcGIS中的地理处理》练习3的时候遇到这个问题,如果你用的是ArcGIS9.2和Python2.5,应该也会遇到这样的问题:Python ImportError: No module named arcgisscripting。

arcgisscripting is a custom dll module that is build against the python24.dll library; you cannot get it to work under python25; you have to use the old style pywin32 system instead.

Assuming you have pywin32 installed for python 2.5, the script below can serve as a wrapper that will allow you to circumvent the problem. Just save it as arcgisscripting.py in your pythonpath

'''----------------------------------------------------------------------------------

arcgisscripting.py

Version: 0.9.1

Author: Philippe Le Grand

Required Argumuments: None

Description:This module serves to replace ESRI's arcgisscripting.dll

on configurations where it is not available

This script is free software; you can redistribute it and/or modify

it under the terms of the GNU General Public License as published by

the Free Software Foundation; either version 2 of the License, or

(at your option) any later version.

This program is distributed in the hope that it will be useful,

but WITHOUT ANY WARRANTY; without even the implied warranty of

MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the

GNU General Public License for more details.

A copy of the GNU General Public License may be obtained

online at

http://www.gnu.org/copyleft/gpl.html

or by writing to the

Free Software Foundation, Inc.,

51 Franklin Street, Fifth Floor,

Boston, MA 02110-1301 USA

----------------------------------------------------------------------------------'''

import win32com.client

def create(licensetype=None):

gp = win32com.client.Dispatch("esriGeoprocessing.GpDispatch.1")

if licensetype is not None:

Licensed=gp.SetProduct(licensetype)

if not (Licensed in ["NotLicensed","Failed"]):

return gp

#Either the licensetype was not set, or it failed

#Try to get the highest possible license

types = ["ArcInfo","ArcEditor","ArcView"]

for license in types:

Licensed=gp.CheckProduct(license)

if not (Licensed in ["NotLicensed","Failed"]):

Licensed = gp.SetProduct(license)

print "geoprocessor started with license: %s (%s)"%(license,Licensed)

return gp

else:

print "license %s is %s"%(license,Licensed)

gp.AddError("No License available for geoprocessor")

raise ValueError,"No License available for geoprocessor"

if (__name__=="__main__"):

gp=create()

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值