jozo / docker-pyqt5

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

qt.qpa.plugin load error. #4

Closed michelejoyce closed 3 years ago

michelejoyce commented 3 years ago

Hi. I'm hoping you can help me. I'm at wit's end.

I am trying to create a PyQt5 application with python3, from my mac.

I have previously solved the XQuartz/x window problem, while writing an app with tkinter. I'm having difficulty getting all of the parts and pieces to work with PyQt5 -- a more modern look and feel.

I have attempted to run your test app, but I get the same error

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

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.

Thanks. Michele

jozo commented 3 years ago

Hi. It seems your $IP variable is empty. Did you run this before?

IP=$(ifconfig en0 | grep inet | awk '$1=="inet" {print $2}')

What is the output of

echo $IP

?

michelejoyce commented 3 years ago

Same error.

IP=$(ifconfig en0 | grep inet | awk '$1=="inet" {print $2}') $ echo $IP

192.168.1.16

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

qt.qpa.xcb: could not connect to display /private/tmp/com.apple.launchd.V4GO9HuUSU/org.macosforge.xquartz: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.

michelejoyce commented 3 years ago

I killed and restarted an xterm. I get the Hello World (whoop!)

A slightly different error: QStandardPaths: XDG_RUNTIME_DIR not set, defaulting to '/tmp/runtime-qtuser' libGL error: No matching fbConfigs or visuals found libGL error: failed to load driver: swrast

I suppose the next question is: Do I simply add your docker image to my docker-compose.py?

jozo commented 3 years ago

Now you have set $IP variable but notice that you don't use it when you call docker. Try again:

docker run --rm -it \
    -v /tmp/.X11-unix:/tmp/.X11-unix \
    -e DISPLAY=$IP:0 \
    -u qtuser \
    jozo/pyqt5 python3 /tmp/hello.py
michelejoyce commented 3 years ago

I did, I had just cut and paste an old command. I can now get the test app up....thanks..

Do I simply add your local build to my docker-compose.py script? Do I have to preface the execution of the application with jozo/pyqt5 python3 mypyapp.py

jozo commented 3 years ago

I suppose the next question is: Do I simply add your docker image to my docker-compose.py?

I don't know what is in your docker-compose.py or how you use it. It's up to you. :) If you need help with your project I recommend to write a question to StackOverflow.