2

I set up PyScripter latest version, 2.7) to work with QGIS (2.2, OSGeo4W install) following http://chelahmy.blogspot.ca/2011/02/setting-up-pyscripter-for-quantum-gis.html. It generally works well. I'm running Windows 7.

Here's my code:

import sys
import os
sys.path.append("C:\\OSGeo4W\\apps\\qgis\\python")
sys.path.append("C:\\OSGeo4W\\apps\\qgis\\python\\plugins")
from qgis.core import *
from qgis.utils import *
from qgis.gui import *
from PyQt4 import *
from PyQt4.QtCore import *
from PyQt4.QtGui import *

from processing.core.Processing import Processing

I need the sys.path.append to import qgis properly (rather than setting them in the PYTHONPATH). However, when I run the line

from processing.core.Processing import Processing

PyScripter simply shuts down, no error message, window just closes. Has anybody else experienced this? Same thing happens with other imports, like

import processing

I can import all the other plugin libraries (GdalTools, fTools, db_manager) with no problems - but I don't need those, I need the proceesing library to access all the nice OTB tools.

  • I just tried running the same code in Eclipse (4.3.2, Aptana, PyDev). When I 'import processing' I get errors like "Can't load requested DLL: C:\Python27\Lib\site-packages\osgeo\gdalplugins\gdal_ECW_JP2ECW.dll". Which is double weird because a) that path is not in my PYTHONPATH (but eve if I add it I get the same message) and b) the specified files are actually in that location. – Anders Apr 4 '14 at 23:26
3

I had the same problem. I fixed it by running a few lines of code before "import processing".

First I created an (unused) application object. "processing" won't work without it and pyscripter will crash.

app = QgsApplication([], True)

Then I "manually" initialized Processing.

from processing.core.Processing import Processing
Processing.initialize()

Not only did the absence of these last two lines cause pyscripter to crash, but I couldn't access the processing algorithms in any environment (not just pyscripter) without them.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.