Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. problem with qt.qpa.plugin: running on a docker in Kubuntu
QtWS25 Last Chance

problem with qt.qpa.plugin: running on a docker in Kubuntu

Scheduled Pinned Locked Moved Unsolved General and Desktop
38 Posts 3 Posters 18.9k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • J Offline
    J Offline
    john_hobbyist
    wrote on last edited by john_hobbyist
    #17

    @eyllanesc said in problem with qt.qpa.plugin: running on a docker in Kubuntu:

    RUN apt-get install -y libxcb-util-dev

    Step 19/21 : RUN apt-get install -y libxcb-util-dev
     ---> Running in ......
    Reading package lists...
    Building dependency tree...
    Reading state information...
    E: Unable to locate package libxcb-util-dev
    The command '/bin/sh -c apt-get install -y libxcb-util-dev' returned a non-zero code: 100
    

    Yes, I saw it now:

    FROM python:3
    
    ADD code.py /
    
    RUN pip3 install opencv-python-headless
    RUN apt-get update ##[edited]
    
    RUN apt-get install ffmpeg libsm6 libxext6  -y
    
    RUN pip3 install matplotlib
    
    RUN apt-get install python3-pyqt5 -y
    
    RUN pip3 install pyqt5
    
    RUN pip3 install wheel
    
    RUN pip3 install pandas
    
    RUN pip3 install openpyxl
    
    RUN pip3 install geopandas
    
    # RUN apt update -y
    
    # RUN apt install libpq-dev -y
    
    # RUN apt install gdal-bin -y
    
    # RUN apt install libgdal-dev -y
    
    RUN pip3 install numba
    
    # RUN pip3 install GDAL
    
    RUN apt-get install qt5-default -y
    
    RUN pip3 install numpy
    
    RUN ldd /usr/lib/x86_64-linux-gnu/qt5/plugins/platforms/libqxcb.so
    
    RUN apt-get update -y
    
    RUN apt-get install -y '^libxcb.*-dev' libx11-xcb-dev libglu1-mesa-dev libxrender-dev libxi-dev libxkbcommon-dev libxkbcommon-x11-dev 
    
    RUN apt-get install -y libxcb-util-dev
    
    ENV QT_DEBUG_PLUGINS=1
    
    CMD [ "python3", "code.py" ]
    

    Any idea???

    eyllanescE 1 Reply Last reply
    0
    • J john_hobbyist

      @eyllanesc said in problem with qt.qpa.plugin: running on a docker in Kubuntu:

      RUN apt-get install -y libxcb-util-dev

      Step 19/21 : RUN apt-get install -y libxcb-util-dev
       ---> Running in ......
      Reading package lists...
      Building dependency tree...
      Reading state information...
      E: Unable to locate package libxcb-util-dev
      The command '/bin/sh -c apt-get install -y libxcb-util-dev' returned a non-zero code: 100
      

      Yes, I saw it now:

      FROM python:3
      
      ADD code.py /
      
      RUN pip3 install opencv-python-headless
      RUN apt-get update ##[edited]
      
      RUN apt-get install ffmpeg libsm6 libxext6  -y
      
      RUN pip3 install matplotlib
      
      RUN apt-get install python3-pyqt5 -y
      
      RUN pip3 install pyqt5
      
      RUN pip3 install wheel
      
      RUN pip3 install pandas
      
      RUN pip3 install openpyxl
      
      RUN pip3 install geopandas
      
      # RUN apt update -y
      
      # RUN apt install libpq-dev -y
      
      # RUN apt install gdal-bin -y
      
      # RUN apt install libgdal-dev -y
      
      RUN pip3 install numba
      
      # RUN pip3 install GDAL
      
      RUN apt-get install qt5-default -y
      
      RUN pip3 install numpy
      
      RUN ldd /usr/lib/x86_64-linux-gnu/qt5/plugins/platforms/libqxcb.so
      
      RUN apt-get update -y
      
      RUN apt-get install -y '^libxcb.*-dev' libx11-xcb-dev libglu1-mesa-dev libxrender-dev libxi-dev libxkbcommon-dev libxkbcommon-x11-dev 
      
      RUN apt-get install -y libxcb-util-dev
      
      ENV QT_DEBUG_PLUGINS=1
      
      CMD [ "python3", "code.py" ]
      

      Any idea???

      eyllanescE Offline
      eyllanescE Offline
      eyllanesc
      wrote on last edited by eyllanesc
      #18

      @john_hobbyist change FROM python:3 to FROM ubuntu:latest. "python: 3" uses a minimalistic version of linux that does not have some packages. Also remove RUN apt-get install qt5-default -y and RUN ldd /usr/lib/x86_64-linux-gnu/qt5/plugins/platforms/libqxcb.so. If you can't find the pip command then add first: RUN apt install python3-pip

      If you want me to help you develop some work then you can write to my email: e.yllanescucho@gmal.com.

      J 1 Reply Last reply
      1
      • eyllanescE eyllanesc

        @john_hobbyist change FROM python:3 to FROM ubuntu:latest. "python: 3" uses a minimalistic version of linux that does not have some packages. Also remove RUN apt-get install qt5-default -y and RUN ldd /usr/lib/x86_64-linux-gnu/qt5/plugins/platforms/libqxcb.so. If you can't find the pip command then add first: RUN apt install python3-pip

        J Offline
        J Offline
        john_hobbyist
        wrote on last edited by john_hobbyist
        #19

        @eyllanesc

        Sending build context to Docker daemon  60.93kB
        Step 1/19 : FROM ubuntu:latest
         ---> ......
        Step 2/19 : ADD code.py /
         ---> Using cache
         ---> .....
        Step 3/19 : RUN pip3 install opencv-python-headless
         ---> Running in .....
        /bin/sh: 1: pip3: not found
        The command '/bin/sh -c pip3 install opencv-python-headless' returned a non-zero code: 127
        UbuntuUser@ubuntu:~/Desktop/test/my_new_docker_build$
        

        Does not run more than this step...

        eyllanescE 1 Reply Last reply
        0
        • J john_hobbyist

          @eyllanesc

          Sending build context to Docker daemon  60.93kB
          Step 1/19 : FROM ubuntu:latest
           ---> ......
          Step 2/19 : ADD code.py /
           ---> Using cache
           ---> .....
          Step 3/19 : RUN pip3 install opencv-python-headless
           ---> Running in .....
          /bin/sh: 1: pip3: not found
          The command '/bin/sh -c pip3 install opencv-python-headless' returned a non-zero code: 127
          UbuntuUser@ubuntu:~/Desktop/test/my_new_docker_build$
          

          Does not run more than this step...

          eyllanescE Offline
          eyllanescE Offline
          eyllanesc
          wrote on last edited by
          #20

          @john_hobbyist mmm, you seem to not fully read my comment: add RUN apt install -y python3-pip before RUN pip3 install opencv-python-headless

          If you want me to help you develop some work then you can write to my email: e.yllanescucho@gmal.com.

          1 Reply Last reply
          1
          • J Offline
            J Offline
            john_hobbyist
            wrote on last edited by
            #21
            Sending build context to Docker daemon  60.93kB
            Step 1/20 : FROM ubuntu:latest
             ---> .....
            Step 2/20 : ADD code.py /
             ---> Using cache
             ---> .....
            Step 3/20 : RUN apt install -y python3-pip
             ---> Running in ......
            
            WARNING: apt does not have a stable CLI interface. Use with caution in scripts.
            
            Reading package lists...
            Building dependency tree...
            Reading state information...
            E: Unable to locate package python3-pip
            The command '/bin/sh -c apt install -y python3-pip' returned a non-zero code: 100
            
            eyllanescE 1 Reply Last reply
            0
            • J john_hobbyist
              Sending build context to Docker daemon  60.93kB
              Step 1/20 : FROM ubuntu:latest
               ---> .....
              Step 2/20 : ADD code.py /
               ---> Using cache
               ---> .....
              Step 3/20 : RUN apt install -y python3-pip
               ---> Running in ......
              
              WARNING: apt does not have a stable CLI interface. Use with caution in scripts.
              
              Reading package lists...
              Building dependency tree...
              Reading state information...
              E: Unable to locate package python3-pip
              The command '/bin/sh -c apt install -y python3-pip' returned a non-zero code: 100
              
              eyllanescE Offline
              eyllanescE Offline
              eyllanesc
              wrote on last edited by
              #22

              @john_hobbyist Use minimal Dockerfile

              FROM ubuntu:latest
              
              RUN apt-get update && apt-get autoclean
              
              RUN apt-get update && apt-get install -y --no-install-recommends python3-pip
              
              RUN pip3 install pyqt5
              
              RUN apt-get install -y '^libxcb.*-dev' libx11-xcb-dev libglu1-mesa-dev libxrender-dev libxi-dev libxkbcommon-dev libxkbcommon-x11-dev 
              
              ENV QT_DEBUG_PLUGINS=1
              
              ADD code.py /
              
              CMD [ "python3", "code.py" ]
              

              If you want me to help you develop some work then you can write to my email: e.yllanescucho@gmal.com.

              J 1 Reply Last reply
              1
              • eyllanescE eyllanesc

                @john_hobbyist Use minimal Dockerfile

                FROM ubuntu:latest
                
                RUN apt-get update && apt-get autoclean
                
                RUN apt-get update && apt-get install -y --no-install-recommends python3-pip
                
                RUN pip3 install pyqt5
                
                RUN apt-get install -y '^libxcb.*-dev' libx11-xcb-dev libglu1-mesa-dev libxrender-dev libxi-dev libxkbcommon-dev libxkbcommon-x11-dev 
                
                ENV QT_DEBUG_PLUGINS=1
                
                ADD code.py /
                
                CMD [ "python3", "code.py" ]
                
                J Offline
                J Offline
                john_hobbyist
                wrote on last edited by john_hobbyist
                #23

                @eyllanesc Ok, it builds this, but I cannot run it obviously because I need the rest packages...

                I included the rest packages on Dockerfile and I get, among others, this again:

                Got keys from plugin meta data ("webgl")
                QFactoryLoader::QFactoryLoader() looking at "/usr/local/lib/python3.8/dist-packages/PyQt5/Qt5/plugins/platforms/libqxcb.so"
                Found metadata in lib /usr/local/lib/python3.8/dist-packages/PyQt5/Qt5/plugins/platforms/libqxcb.so, metadata=
                {
                    "IID": "org.qt-project.Qt.QPA.QPlatformIntegrationFactoryInterface.5.3",
                    "MetaData": {
                        "Keys": [
                            "xcb"
                        ]
                    },
                    "archreq": 0,
                    "className": "QXcbIntegrationPlugin",
                    "debug": false,
                    "version": 331520
                }
                
                
                Got keys from plugin meta data ("xcb")
                QFactoryLoader::QFactoryLoader() checking directory path "/usr/bin/platforms" ...
                loaded library "/usr/local/lib/python3.8/dist-packages/PyQt5/Qt5/plugins/platforms/libqxcb.so"
                qt.qpa.xcb: could not connect to display 
                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, wayland-egl, wayland, wayland-xcomposite-egl, wayland-xcomposite-glx, webgl, xcb.
                

                Any idea??

                1 Reply Last reply
                0
                • SGaistS Offline
                  SGaistS Offline
                  SGaist
                  Lifetime Qt Champion
                  wrote on last edited by
                  #24

                  As said earlier, Docker does not have access to your X server.

                  There are several ways to achieve that but it looks like this tool is quite interesting.

                  Interested in AI ? www.idiap.ch
                  Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                  1 Reply Last reply
                  2
                  • J Offline
                    J Offline
                    john_hobbyist
                    wrote on last edited by
                    #25

                    When I run an image I see the result on my pc? I mean the application result is displayed on my pc?

                    1 Reply Last reply
                    0
                    • SGaistS Offline
                      SGaistS Offline
                      SGaist
                      Lifetime Qt Champion
                      wrote on last edited by
                      #26

                      That's the goal of the tool, to allow the application to connect to an X server so that it can display its content.

                      Interested in AI ? www.idiap.ch
                      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                      1 Reply Last reply
                      2
                      • J Offline
                        J Offline
                        john_hobbyist
                        wrote on last edited by
                        #27

                        Because now I hit: "sudo docker run <IMAGE ID>" the OS does not complain with errors or something, but I do not see the application running on my laptop...What is going on?

                        1 Reply Last reply
                        0
                        • SGaistS Offline
                          SGaistS Offline
                          SGaist
                          Lifetime Qt Champion
                          wrote on last edited by
                          #28

                          Check the logs of your container.

                          And if I may, you should avoid running docker using sudo. Add your user to the docker group so you can do things directly.

                          Interested in AI ? www.idiap.ch
                          Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                          1 Reply Last reply
                          2
                          • J Offline
                            J Offline
                            john_hobbyist
                            wrote on last edited by
                            #29

                            So the problem is that Docker cannot run PyQt/GUI application, if I have understood correctly??

                            1 Reply Last reply
                            0
                            • SGaistS Offline
                              SGaistS Offline
                              SGaist
                              Lifetime Qt Champion
                              wrote on last edited by
                              #30

                              It may but you have additional work do to in order for it to be able to do that as shown by the tool I suggested above.

                              Interested in AI ? www.idiap.ch
                              Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                              1 Reply Last reply
                              2
                              • J Offline
                                J Offline
                                john_hobbyist
                                wrote on last edited by
                                #31

                                I found this tutorial: https://stackoverflow.com/questions/24095968/docker-for-gui-based-environments which as I see matches with https://github.com/mviereck/x11docker (that you posted), however I cannot understand if this command:

                                nividia-docker run --interactive --tty --env DISPLAY=$DISPLAY --volume /tmp/.X11-unix/:/tmp/.X11-unix/ <docker_iamge> 
                                

                                demands to have NVIDIA GPU?? I run the docker on Kubuntu 20.04.1 LTS running on a VMware, so I cannot access GPU...

                                1 Reply Last reply
                                0
                                • SGaistS Offline
                                  SGaistS Offline
                                  SGaist
                                  Lifetime Qt Champion
                                  wrote on last edited by
                                  #32

                                  You can use that one if you have setup docker to run with NVIDIA hardware however, you can see from the main answer that it's not required at all.

                                  Interested in AI ? www.idiap.ch
                                  Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                                  1 Reply Last reply
                                  1
                                  • J Offline
                                    J Offline
                                    john_hobbyist
                                    wrote on last edited by john_hobbyist
                                    #33

                                    So, what are the steps to make this tool https://github.com/mviereck/x11docker#single-applications work and generally to make the PyQt GUI application run on the docker?? Because I have tried a few tutorials, such as this: https://askubuntu.com/questions/1161646/is-it-possible-to-run-docker-container-and-show-its-graphical-application-window and this: https://askubuntu.com/questions/1249043/run-simple-x11-app-in-docker-container-on-ubuntu-20-04 and the only thing I get is errors!!

                                    Such as this one:

                                    Sending build context to Docker daemon  2.048kB
                                    Step 1/4 : FROM ubuntu:20.10
                                     ---> .....
                                    Step 2/4 : RUN apt-get update
                                     ---> Using cache
                                     ---> .....
                                    Step 3/4 : RUN apt-get install -y x11-apps
                                     ---> Running in .....
                                    Reading package lists...
                                    Building dependency tree...
                                    Reading state information...
                                    E: Unable to locate package x11-apps
                                    The command '/bin/sh -c apt-get install -y x11-apps' returned a non-zero code: 100
                                    
                                    1 Reply Last reply
                                    0
                                    • SGaistS Offline
                                      SGaistS Offline
                                      SGaist
                                      Lifetime Qt Champion
                                      wrote on last edited by
                                      #34

                                      X11-apps is not available on x86_64 architecture for Ubuntu 20.10.

                                      In any case, you should not need it to run your application.

                                      Interested in AI ? www.idiap.ch
                                      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                                      1 Reply Last reply
                                      1
                                      • J Offline
                                        J Offline
                                        john_hobbyist
                                        wrote on last edited by john_hobbyist
                                        #35
                                        This post is deleted!
                                        1 Reply Last reply
                                        0
                                        • J Offline
                                          J Offline
                                          john_hobbyist
                                          wrote on last edited by john_hobbyist
                                          #36

                                          Ok, after many days searching and experimenting I made this Dockerfile run:

                                          FROM ubuntu:14.04
                                          
                                          RUN apt-get update && apt-get install -y firefox
                                          
                                          # Replace 1000 with your user / group id
                                          RUN export uid=1000 gid=1000 && \
                                              mkdir -p /home/developer && \
                                              echo "developer:x:${uid}:${gid}:Developer,,,:/home/developer:/bin/bash" >> /etc/passwd && \
                                              echo "developer:x:${uid}:" >> /etc/group && \
                                              echo "developer ALL=(ALL) NOPASSWD: ALL" > /etc/sudoers.d/developer && \
                                              chmod 0440 /etc/sudoers.d/developer && \
                                              chown ${uid}:${gid} -R /home/developer
                                          
                                          USER developer
                                          ENV HOME /home/developer
                                          CMD /usr/bin/firefox
                                          

                                          source: http://fabiorehm.com/blog/2014/09/11/running-gui-apps-with-docker/

                                          What modifications should I do in order to make my .py code file, inside which I use PyQt libraries, run???

                                          Thanks...

                                          1 Reply Last reply
                                          0

                                          • Login

                                          • Login or register to search.
                                          • First post
                                            Last post
                                          0
                                          • Categories
                                          • Recent
                                          • Tags
                                          • Popular
                                          • Users
                                          • Groups
                                          • Search
                                          • Get Qt Extensions
                                          • Unsolved