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)


from processing.core.Processing import Processing
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:

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

Your Answer

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

Browse other questions tagged or ask your own question.