jozo / docker-pyqt5

Dockerfile for development of GUI applications with Python 3 + PyQt5
83 stars 24 forks source link

Error on Archlinux with i3wm: qt.qpa.xcb: could not connect to display :0 #7

Open foersben opened 3 years ago

foersben commented 3 years ago

Greetings,

I am trying to run the linux example:

docker run --rm -it \
    -v /tmp/.X11-unix:/tmp/.X11-unix \
    -e DISPLAY=$DISPLAY \
    -u qtuser \
    jozo/pyqt5 python3 /tmp/hello.py

and receive the following error message:

No protocol specified
qt.qpa.xcb: could not connect to display :0
qt.qpa.plugin: Could not load the Qt platform plugin "xcb" in "" even though it was found.
This application failed to start because no Qt platform plugin could be initialized. Reinstalling the application may fix this problem.

Available platform plugins are: eglfs, linuxfb, minimal, minimalegl, offscreen, vnc, xcb.

Not sure what the exact problem is but my hostname is set, $DISPLAY is set to :0 by default, whether that is correct or not is something I don't know. The primary and currently only Display of my notebook is (following xrandr):

Screen 0: minimum 320 x 200, current 3840 x 2160, maximum 16384 x 16384
eDP-1 connected primary 3840x2160+0+0 (normal left inverted right x axis y axis) 344mm x 194mm
nPaul commented 3 years ago

Greetings,

I am trying to run the linux example:

docker run --rm -it \
    -v /tmp/.X11-unix:/tmp/.X11-unix \
    -e DISPLAY=$DISPLAY \
    -u qtuser \
    jozo/pyqt5 python3 /tmp/hello.py

and receive the following error message:

No protocol specified
qt.qpa.xcb: could not connect to display :0
qt.qpa.plugin: Could not load the Qt platform plugin "xcb" in "" even though it was found.
This application failed to start because no Qt platform plugin could be initialized. Reinstalling the application may fix this problem.

Available platform plugins are: eglfs, linuxfb, minimal, minimalegl, offscreen, vnc, xcb.

Not sure what the exact problem is but my hostname is set, $DISPLAY is set to :0 by default, whether that is correct or not is something I don't know. The primary and currently only Display of my notebook is (following xrandr):

Screen 0: minimum 320 x 200, current 3840 x 2160, maximum 16384 x 16384
eDP-1 connected primary 3840x2160+0+0 (normal left inverted right x axis y axis) 344mm x 194mm

you need run $ xhost +local:root

foersben commented 3 years ago

@nPaul thanks, that solved it or to be more precise:

$ xhost +local:docker

was enough to make it work, but thank you very much :D

hiepbk commented 5 months ago

Greetings, I am trying to run the linux example:

docker run --rm -it \
    -v /tmp/.X11-unix:/tmp/.X11-unix \
    -e DISPLAY=$DISPLAY \
    -u qtuser \
    jozo/pyqt5 python3 /tmp/hello.py

and receive the following error message:

No protocol specified
qt.qpa.xcb: could not connect to display :0
qt.qpa.plugin: Could not load the Qt platform plugin "xcb" in "" even though it was found.
This application failed to start because no Qt platform plugin could be initialized. Reinstalling the application may fix this problem.

Available platform plugins are: eglfs, linuxfb, minimal, minimalegl, offscreen, vnc, xcb.

Not sure what the exact problem is but my hostname is set, $DISPLAY is set to :0 by default, whether that is correct or not is something I don't know. The primary and currently only Display of my notebook is (following xrandr):

Screen 0: minimum 320 x 200, current 3840 x 2160, maximum 16384 x 16384
eDP-1 connected primary 3840x2160+0+0 (normal left inverted right x axis y axis) 344mm x 194mm

you need run $ xhost +local:root

It's work for me.