Python QGIS处理作业的调度
我正试图编写一个独立的QGIS Python脚本,以便在夜间由计划任务运行,但在导入处理模块时,我在一开始就陷入了困境——我得到的错误状态是:“没有名为processing.core.processing的模块”。我在互联网上搜索了一个解决方案,但似乎找不到任何可行的方法。下面是我正在尝试运行的内容:Python QGIS处理作业的调度,python,python-2.7,scheduled-tasks,qgis,Python,Python 2.7,Scheduled Tasks,Qgis,我正试图编写一个独立的QGIS Python脚本,以便在夜间由计划任务运行,但在导入处理模块时,我在一开始就陷入了困境——我得到的错误状态是:“没有名为processing.core.processing的模块”。我在互联网上搜索了一个解决方案,但似乎找不到任何可行的方法。下面是我正在尝试运行的内容: import sys from PyQt4.QtGui import * from qgis.core import * # Initialize QGIS Application app =
import sys
from PyQt4.QtGui import *
from qgis.core import *
# Initialize QGIS Application
app = QgsApplication([], True)
QgsApplication.setPrefixPath("C:\Program Files\QGIS Pisa\apps\qgis", True)
QgsApplication.initQgis()
# Add the path to Processing framework
sys.path.append('C:\Users\andreeam.popa\.qgis2\python\plugins\processing')
# Import and initialize Processing framework
from processing.core.Processing import Processing
Processing.initialize()
from processing.tools import *
print 'Hello QGIS!'
这是启动上述程序的批处理文件:
REM Change OSGEO4W_ROOT to point to the base install folder
SET OSGEO4W_ROOT=C:\Program Files\QGIS Pisa
SET QGISNAME=qgis
SET QGIS=%OSGEO4W_ROOT%\apps\%QGISNAME%
set QGIS_PREFIX_PATH=%QGIS%
REM Gdal Setup
set GDAL_DATA=%OSGEO4W_ROOT%\share\gdal\
REM Python Setup
set PATH=%OSGEO4W_ROOT%\bin;%QGIS%\bin;%PATH%
SET PYTHONHOME=%OSGEO4W_ROOT%\apps\Python27
set PYTHONPATH=%QGIS%\python;%PYTHONPATH%
REM Launch python job
python X:\FunGis\Workspaces\Andreea\MyScripts\QGIS_Scripts\test.py
pause"
欢迎提出任何意见。
谢谢。问题现在解决了。我必须更改sys.path.append到
c:\\Program Files\\QGIS-Wien\\apps\\QGIS\\python\\plugins
而不是c:\\Users\\username\\.qgis2\\python\\plugins