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. Run a Python Qt application on Ubuntu 20.04

Run a Python Qt application on Ubuntu 20.04

Scheduled Pinned Locked Moved Unsolved General and Desktop
12 Posts 4 Posters 3.7k 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.
  • P Offline
    P Offline
    PythonQTMarlem
    wrote on 27 May 2020, 10:03 last edited by
    #1

    Hi,

    I'm developing Python and Qt on Windows 10.

    Question:
    What steps are required in the Ubuntu 20.04 operating system so that a
    Python Qt application can be started on Ubuntu?

    J 1 Reply Last reply 27 May 2020, 10:15
    0
    • P PythonQTMarlem
      27 May 2020, 10:03

      Hi,

      I'm developing Python and Qt on Windows 10.

      Question:
      What steps are required in the Ubuntu 20.04 operating system so that a
      Python Qt application can be started on Ubuntu?

      J Online
      J Online
      JonB
      wrote on 27 May 2020, 10:15 last edited by JonB
      #2

      @PythonQTMarlem
      Personally I do everything I can under Ubuntu via apt-get, that gives me the Qt release accompanying the OS when released, I do not need the latest version and do not want to have to compile Qt sources.

      Ubuntu already has Python 3 installed.

      For Python Qt, you must decide whether you want to use PyQt5 or PySide 2. You can get either of these via apt-get too; you can also use pip3, and possibly virtual environments if that's your thing. Personally I would recommend PySide 2 over PyQt5 just for the licensing, but presumably you have already made your choice on Windows anyway. If you want to develop you must also choose your IDE suitably, maybe Qt Creator, maybe PyCharm, VSCode only if you have to IMO.

      You may also want to look at linuxdeployqt if you want to run but not develop. I don't know whether you can do that from Windows.

      P.S.
      Don't forget that under Ubuntu, Python 3 interpreter is python3, not python!

      1 Reply Last reply
      2
      • P Offline
        P Offline
        PythonQTMarlem
        wrote on 27 May 2020, 14:54 last edited by PythonQTMarlem
        #3

        Thanks for the answer. I want to use PyQt5. I have already installed PyCharm. when I call in the terminal:

        sudo apt-get install python3-pyqt5 the message "python3-pyqt5 is already the latest version (5.14.1 + dfsg-3build1)".
        

        If I want to do this in the terminal:

        / home / markus / PycharmProjects / PythonTest / venv / bin / python /home/markus/PycharmProjects/PythonTest/Ubuntu.py
        

        comes the error message: raceback (most recent call last):
          File "/home/markus/PycharmProjects/PythonTest/Ubuntu.py", line 2, in <module>
            from qtpy import QtWidgets
        ModuleNotFoundError: No module named 'qtpy'

        Question: What am I doing wrong?

        J J 2 Replies Last reply 27 May 2020, 15:47
        0
        • P PythonQTMarlem
          27 May 2020, 14:54

          Thanks for the answer. I want to use PyQt5. I have already installed PyCharm. when I call in the terminal:

          sudo apt-get install python3-pyqt5 the message "python3-pyqt5 is already the latest version (5.14.1 + dfsg-3build1)".
          

          If I want to do this in the terminal:

          / home / markus / PycharmProjects / PythonTest / venv / bin / python /home/markus/PycharmProjects/PythonTest/Ubuntu.py
          

          comes the error message: raceback (most recent call last):
            File "/home/markus/PycharmProjects/PythonTest/Ubuntu.py", line 2, in <module>
              from qtpy import QtWidgets
          ModuleNotFoundError: No module named 'qtpy'

          Question: What am I doing wrong?

          J Online
          J Online
          JonB
          wrote on 27 May 2020, 15:47 last edited by JonB
          #4

          @PythonQTMarlem said in Run a Python Qt application on Ubuntu 20.04:

          from qtpy import QtWidgets

          I have never heard of from qtpy anything, so where do you get that from/why do you expect it to generate anythong other than

          ModuleNotFoundError: No module named 'qtpy'

          ?

          Furthermore, although the spacing of your command line seems incorrect, you seem to be running python as the name of the executable? I don't know about your venv/bin/python, but did you take the trouble to read what I wrote earlier about this to verify that's correct?

          Finally, if you are using Python virtual environments, you're on your own for checking the docs about whatever you need to get that working correctly.

          P 1 Reply Last reply 27 May 2020, 16:05
          1
          • J JonB
            27 May 2020, 15:47

            @PythonQTMarlem said in Run a Python Qt application on Ubuntu 20.04:

            from qtpy import QtWidgets

            I have never heard of from qtpy anything, so where do you get that from/why do you expect it to generate anythong other than

            ModuleNotFoundError: No module named 'qtpy'

            ?

            Furthermore, although the spacing of your command line seems incorrect, you seem to be running python as the name of the executable? I don't know about your venv/bin/python, but did you take the trouble to read what I wrote earlier about this to verify that's correct?

            Finally, if you are using Python virtual environments, you're on your own for checking the docs about whatever you need to get that working correctly.

            P Offline
            P Offline
            PythonQTMarlem
            wrote on 27 May 2020, 16:05 last edited by PythonQTMarlem
            #5

            @JonB said in [Run a Python Qt application on Ubuntu 20 \ .04] (/ post / 597283):

            @PythonQTMarlem said in [Run a Python Qt application on Ubuntu 20 \ .04] (/ post / 597262):

            from qtpy import QtWidgets

            I saw it in a Youtube video.
            probably comes from:
            ''
            import os, sys
            from PyQt5 import QtCore, QtWidgets
            ''

            J 1 Reply Last reply 27 May 2020, 16:17
            0
            • P PythonQTMarlem
              27 May 2020, 16:05

              @JonB said in [Run a Python Qt application on Ubuntu 20 \ .04] (/ post / 597283):

              @PythonQTMarlem said in [Run a Python Qt application on Ubuntu 20 \ .04] (/ post / 597262):

              from qtpy import QtWidgets

              I saw it in a Youtube video.
              probably comes from:
              ''
              import os, sys
              from PyQt5 import QtCore, QtWidgets
              ''

              J Online
              J Online
              JonB
              wrote on 27 May 2020, 16:17 last edited by
              #6

              @PythonQTMarlem
              I don't understand. That says

              from PyQt5 import QtWidgets
              

              But you say your code has

              from qtpy import QtWidgets
              

              with error

              ModuleNotFoundError: No module named 'qtpy'

              So I'm still not understanding where you get to use qtpy from?

              1 Reply Last reply
              1
              • P Offline
                P Offline
                PythonQTMarlem
                wrote on 27 May 2020, 17:00 last edited by
                #7

                @JonB said in Run a Python Qt application on Ubuntu 20.04:

                PyQt5
                how can I check if the installation of PyQt5 in Ubuntu was successful?

                J 1 Reply Last reply 27 May 2020, 17:07
                0
                • P PythonQTMarlem
                  27 May 2020, 17:00

                  @JonB said in Run a Python Qt application on Ubuntu 20.04:

                  PyQt5
                  how can I check if the installation of PyQt5 in Ubuntu was successful?

                  J Online
                  J Online
                  JonB
                  wrote on 27 May 2020, 17:07 last edited by
                  #8

                  @PythonQTMarlem
                  You wrote earlier:

                  sudo apt-get install python3-pyqt5 the message "python3-pyqt5 is already the latest version (5.14.1 + dfsg-3build1)".

                  S 1 Reply Last reply 27 May 2020, 17:10
                  0
                  • J JonB
                    27 May 2020, 17:07

                    @PythonQTMarlem
                    You wrote earlier:

                    sudo apt-get install python3-pyqt5 the message "python3-pyqt5 is already the latest version (5.14.1 + dfsg-3build1)".

                    S Offline
                    S Offline
                    SGaist
                    Lifetime Qt Champion
                    wrote on 27 May 2020, 17:10 last edited by
                    #9

                    @JonB AFAIK, qtpy is one of the Python wrappers that allows to use either version of PySide2 or PyQt5 with the same code base.

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

                    J 1 Reply Last reply 27 May 2020, 17:16
                    2
                    • S SGaist
                      27 May 2020, 17:10

                      @JonB AFAIK, qtpy is one of the Python wrappers that allows to use either version of PySide2 or PyQt5 with the same code base.

                      J Online
                      J Online
                      JonB
                      wrote on 27 May 2020, 17:16 last edited by JonB
                      #10

                      @SGaist said in Run a Python Qt application on Ubuntu 20.04:

                      @JonB AFAIK, qtpy is one of the Python wrappers that allows to use either version of PySide2 or PyQt5 with the same code base.

                      Ohhhhh! :)

                      Well in that case it's not doing a very good job if the OP reports:

                      comes the error message: raceback (most recent call last):
                        File "/home/markus/PycharmProjects/PythonTest/Ubuntu.py", line 2, in <module>
                          from qtpy import QtWidgets
                      ModuleNotFoundError: No module named 'qtpy'
                      

                      :) It's not the QtWidgets that's at issue, it's the qtpy. So doesn't he have to install something for qtpy, presumably? Perhaps to do with where the OP is looking, or I've even suggested he might be executing Python 2....

                      1 Reply Last reply
                      0
                      • S Offline
                        S Offline
                        SGaist
                        Lifetime Qt Champion
                        wrote on 27 May 2020, 17:56 last edited by
                        #11

                        The wrapper has to be installed like any other Python module.

                        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
                        • P PythonQTMarlem
                          27 May 2020, 14:54

                          Thanks for the answer. I want to use PyQt5. I have already installed PyCharm. when I call in the terminal:

                          sudo apt-get install python3-pyqt5 the message "python3-pyqt5 is already the latest version (5.14.1 + dfsg-3build1)".
                          

                          If I want to do this in the terminal:

                          / home / markus / PycharmProjects / PythonTest / venv / bin / python /home/markus/PycharmProjects/PythonTest/Ubuntu.py
                          

                          comes the error message: raceback (most recent call last):
                            File "/home/markus/PycharmProjects/PythonTest/Ubuntu.py", line 2, in <module>
                              from qtpy import QtWidgets
                          ModuleNotFoundError: No module named 'qtpy'

                          Question: What am I doing wrong?

                          J Offline
                          J Offline
                          jsulm
                          Lifetime Qt Champion
                          wrote on 28 May 2020, 05:35 last edited by
                          #12

                          @PythonQTMarlem said in Run a Python Qt application on Ubuntu 20.04:

                          / home / markus / PycharmProjects / PythonTest / venv / bin / python

                          Try with python3 instead with python as python on Ubuntu means Python 2, but you installed for Python 3. @JonB already mentioned that, but it seems you ignored that?

                          https://forum.qt.io/topic/113070/qt-code-of-conduct

                          1 Reply Last reply
                          0

                          9/12

                          27 May 2020, 17:10

                          • Login

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