+ -
当前位置:首页 → 问答吧 → 如何双击运行含有arcpy模块的python程序

如何双击运行含有arcpy模块的python程序

时间:2011-11-08

来源:互联网

arcpy是ArcGIS模块。我想双击运行python,然后把python程序放在Windows计划任务里可以每天执行。所以双击运行很重要,但如果程序里含有import arcpy后就不可以双击运行了。举个最简单的例子,


import os, shutil

shutil.rmtree('C:\Documents and Settings\Desktop\New Folder 1\info')

这个程序可以双击运行,但我加上arcpy后就不可以双击运行了,但这个程序在IDLE中是可以运行的。

import os, shutil, arcpy

shutil.rmtree('C:\Documents and Settings\yao.shen\Desktop\New Folder 1\info')


是不是我还有设置什么路径呢?谢谢!

作者: rainbowyao1230   发布时间: 2011-11-08

我找到解决办法了:

When you try to launch a script automatically by double-clicking it, it's possible you'll get a message saying Windows doesn't know which program to use to open your file. If this happens to you, use the Browse button on the error dialog box to browse to the Python executable, most likely located in C:\Python26\ArcGIS10.0\Python.exe. Make sure Always use the selected program to open this kind of file is checked and click OK. Windows now understands that .py files should be run using Python.

作者: rainbowyao1230   发布时间: 2011-11-08