3

I'm trying to run the QGIS 'intersection' algorithm from a Python script: (Working with Ubuntu)

#!/usr/bin/env python
# -*- coding: UTF-8 -*-

import sys
from qgis.core import *
from PyQt4.QtGui import *

app = QApplication(sys.argv, False)
QgsApplication.setPrefixPath("/usr", True)
QgsApplication.initQgis()

sys.path.append('/usr/share/qgis/python/plugins')

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

processing.runalg("qgis:intersection","dbname='/path_to_DB/db1.sqlite' table='table1' (geometry) sql=","dbname='/path_to_DB/db2.sqlite' table='table2' (geometry) sql=","/path_to_output/output.shp")

I get the following error: "QPixmap: Cannot create a QPixmap when no GUI is being used".

I need my script to run without using a graphical interface.

Is there a problem with QApplication? Was it created to run exclusively with True as an argument? Is the problem in my script?

I've looked at many related questions but couldn't find the solution:

3
  • Try moving app = QApplication(sys.argv, False) below QgsApplication.setPrefixPath("/usr", True).
    – Joseph
    Commented Jun 16, 2016 at 9:36
  • @Joseph Thank's for your comment. Just tried it, I still get the same error.
    – EliseB
    Commented Jun 16, 2016 at 9:52
  • Have you an another qgis running ?
    – SIGIS
    Commented Jun 23, 2016 at 22:24

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.