[Qgis-developer] Error : cannot connect to X server on Ubuntu

Matthias Kuhn matthias.kuhn at gmx.ch
Wed Dec 10 11:52:57 PST 2014


The tests run on a headless server with xvfb.

So I assume that doing anything with

xvfb-run python yourapp.py

and no messing with display should work perfectly as well.

On 12/10/2014 08:50 PM, devquestions2 at gmail.com wrote:
> Yeah, I am trying to use headless application. I was able to overcome the
> earlier error, but now i am stuck with a new error message.
>
> "QPixmap: Cannot create a QPixmap when no GUI is being used"
> "QPixmap: Cannot create a QPixmap when no GUI is being used"
> "QPixmap: Cannot create a QPixmap when no GUI is being used"
>
> Now I am creating QApplication by passing flase for ui mode.
>>> app = QgsApplication([], False)
> Here is the revised code.
>
> I thought someone should figured this out before.  It is so painful to use
> qgis in headless mode !!
>
>
> 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
>
>
>
> --
> View this message in context: http://osgeo-org.1560.x6.nabble.com/Error-cannot-connect-to-X-server-on-Ubuntu-tp5177029p5177312.html
> Sent from the Quantum GIS - Developer mailing list archive at Nabble.com.
> _______________________________________________
> Qgis-developer mailing list
> Qgis-developer at lists.osgeo.org
> http://lists.osgeo.org/mailman/listinfo/qgis-developer



More information about the Qgis-developer mailing list