简体   繁体   中英

Apache mod_wsgi and Qt

I'm getting an error in Apache error_log with WSGI and PyQt4 :

: cannot connect to X server

My Python code looks like :

import PyQt4.qtgui as qtgui
__qt_app = qtgui.QApplication([])

I had a minimal CentOS installation and I had to install lightweight X server (group "X Window System" and some other rpms).

Previous code is working in a console after the X server installation (before was not).

Environment : CentOS 6.5, Apache 2.2.15, mod_wsgi 4.3.0.

Any clue about what could happening ?

I found a "solution", i re-installed minimal CentOS (i don't need X server) and i added the xorg-x11-server-Xvfb package.

Start Xvfb on display 99 :

/usr/bin/Xvfb :99 -screen 0 640x480x24

Edit python code :

import os
import PyQt4.qtgui as qtgui

os.environ['DISPLAY'] = ':99'
__qt_app = qtgui.QApplication([])

And everything is working.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM