[Qgis-developer] Error : cannot connect to X server on Ubuntu
rdmailings at duif.net
Tue Dec 9 05:47:01 PST 2014
On 09-12-14 14:16, devquestions2 at gmail.com wrote:
> I am seeing the error "cannot connect to X server" in a stand alone python
> application at
> "app = QgsApplication(, True)".
> As suggested in the mailing archives I tried setting DISPLAY env variable to
> "", but that does not resolve the problem. Would be a great help if you can
> point me any references on the issue or have any suggestions on what i can
> Os Ubuntu
> code :
> import os
> import sys
> #qgisprefix = '/usr'
> from qgis.core import *
> from qgis.gui import *_
> # configure QGIS paths
> QgsApplication.setPrefixPath(qgisprefix, True)
> # initalise QGIS
> app = QgsApplication(, True)
I'm on Debian here, and (given the right PYTHONPATH and LD_LIBRARY path
are correct), your code works for me.
Martin tells something about the differences between the inits of qgis.
Setting the DISPLAY to "" as you do is actually setting it to NONE!
If you are in a X-session you should not need to set this. If you are
running it on a headless server, then it is possible you do not have X.
Are you sure ubuntu is actually running X? Wasn't ubuntu busy with
trying to make something else instead of X, mir or so?
Can you try it on another machine?
More information about the Qgis-developer