主角:
Xvfb ? virtual framebuffer X server for X Version 11
需要在服務(wù)器用一個(gè)基于 PyQt 的程序畫(huà)圖葱椭,而 PyQt 要求有 X server 支持捂寿。服務(wù)器上一般不會(huì)裝 X Window的,這時(shí)候就輪到 Xvfb出場(chǎng)了孵运!
對(duì)于 Xvfb 并不了解秦陋,我是在遇到問(wèn)題后 google 到的解決方案,下面是官方的描述:
Xvfb is an X server that can run on machines with no display hardware and no physical input devices. It emulates a dumb framebuffer using virtual memory.
- 安裝
- 啟動(dòng) Xvfb
Xvfb -ac :7 -screen 0 1280x1024x8 > /dev/null 2>&1
export DISPLAY=:7
# DISPLAY 后的編號(hào)須與啟動(dòng)時(shí)的編號(hào)一致治笨,這里是 ":7"驳概。
之后就可以像在X Window中一樣使用各種GUI程序了。
Python 中還有更原生的方式:PyVirtualDisplay