0

I had installed QGIS with it in ubuntu :

sudo apt-get install qgis python-qgis qgis-plugin-grass

refer to this guide : https://www.qgis.org/en/site/forusers/alldownloads.html

then i try to import QGIS module that usually work in Windows QGIS Desktop application such as :

from qgis.core import *
from osgeo import *

but then, i try to :

import processing

and it said:

No module named processing

Ok i see since this is run as external application, so i try to do something like this:

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

but what i've got is:

QPixmap: Must construct a QApplication before a QPaintDevice
Aborted (core dumped)

Then i my python console was exited automatically

So my question is, how to import processing in ubuntu python console that had been QGIS installed?

I really need this module..

Faizalprabowo
  • 702
  • 2
  • 6
  • 20

1 Answers1

2

refer to this link, http://osgeo-org.1560.x6.nabble.com/Error-cannot-connect-to-X-server-on-Ubuntu-td5177029.html

This is how to import processing

import os 
import sys 

qgisprefix = '/usr' 
#qgisprefix='/usr/share/qgis/resources' 

# configure paths for QGIS 
sys.path.insert(0, qgisprefix+'/share/qgis/python') 
sys.path.insert(1, qgisprefix+'/share/qgis/python/plugins') 

# disable QGIS debug messages 
#os.environ['QGIS_DEBUG'] = '-1' 
os.environ['DISPLAY']="" 
# import QGIS modules 
from qgis.core import * 

#from qgis.gui import * 

# configure QGIS paths 
QgsApplication.setPrefixPath(qgisprefix, False) 

# initalise QGIS 
QgsApplication.initQgis() 

app = QgsApplication([], False) 

import processing
Faizalprabowo
  • 702
  • 2
  • 6
  • 20