Skip to main content
Tweeted twitter.com/StackGIS/status/941998241931022336
replaced http://gis.stackexchange.com/ with https://gis.stackexchange.com/
Source Link

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:

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:

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:

Source Link
EliseB
  • 363
  • 1
  • 4
  • 13

Cannot run QGIS algorithm with python script without interface

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: