Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Design Tooling
  3. Qt Design Studio
  4. Unable to Open File
Forum Updated to NodeBB v4.3 + New Features

Unable to Open File

Scheduled Pinned Locked Moved Solved Qt Design Studio
11 Posts 2 Posters 2.4k 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.
  • V vidyul
    26 Feb 2024, 12:24

    Hello Guys I am currently working on the project where I have created a ui file using Qt Designer and I am trying to Load that particular UI file but it is giving me an error:

    Traceback (most recent call last):
    File "/home/xanthas/Desktop/ATE/ATE_SOFTWARE_V3/v2_main.py", line 233, in Fixed_Wing_connect
    ATE_OBJ_Fixed_Wing=Fixed_Wing_UI()
    File "/home/xanthas/Desktop/ATE/ATE_SOFTWARE_V3/v2_main.py", line 130, in init
    loadUi('Fixed_Wing.ui',self)
    File "/home/xanthas/.local/lib/python3.8/site-packages/PyQt5/uic/init.py", line 241, in loadUi
    return DynamicUILoader(package).loadUi(uifile, baseinstance, resource_suffix)
    File "/home/xanthas/.local/lib/python3.8/site-packages/PyQt5/uic/Loader/loader.py", line 66, in loadUi
    return self.parse(filename, resource_suffix)
    File "/home/xanthas/.local/lib/python3.8/site-packages/PyQt5/uic/uiparser.py", line 1020, in parse
    document = parse(filename)
    File "/usr/lib/python3.8/xml/etree/ElementTree.py", line 1202, in parse
    tree.parse(source, parser)
    File "/usr/lib/python3.8/xml/etree/ElementTree.py", line 584, in parse
    source = open(source, "rb")
    FileNotFoundError: [Errno 2] No such file or directory: 'Fixed_Wing.ui'

    But the file is in the same folder as that of the main file. What could be the issue?

    J Offline
    J Offline
    JonB
    wrote on 26 Feb 2024, 12:32 last edited by
    #2

    @vidyul
    You are using a relative pathname. That means it will only be found if the current directory is where the file is. That depends on how you started the program from where. I don't know whether Python changes the current directory to where the invoked .py file is located. You can check this and/or use a full path to the file.

    V 1 Reply Last reply 27 Feb 2024, 04:11
    0
    • J JonB
      26 Feb 2024, 12:32

      @vidyul
      You are using a relative pathname. That means it will only be found if the current directory is where the file is. That depends on how you started the program from where. I don't know whether Python changes the current directory to where the invoked .py file is located. You can check this and/or use a full path to the file.

      V Offline
      V Offline
      vidyul
      wrote on 27 Feb 2024, 04:11 last edited by
      #3

      @JonB All my files are in the same directory as I mentioned above then too it is not opening.

      J 1 Reply Last reply 27 Feb 2024, 08:44
      0
      • V vidyul
        27 Feb 2024, 04:11

        @JonB All my files are in the same directory as I mentioned above then too it is not opening.

        J Offline
        J Offline
        JonB
        wrote on 27 Feb 2024, 08:44 last edited by JonB
        #4

        @vidyul
        I don't see how that addresses the possible issue.

        FileNotFoundError: [Errno 2] No such file or directory: 'Fixed_Wing.ui'

        Did you at least take the 10 seconds to try passing the full path to Fixed_Wing.ui in loadUi('.../Fixed_Wing.ui',self), then we would be sure?

        V 1 Reply Last reply 27 Feb 2024, 09:02
        0
        • J JonB
          27 Feb 2024, 08:44

          @vidyul
          I don't see how that addresses the possible issue.

          FileNotFoundError: [Errno 2] No such file or directory: 'Fixed_Wing.ui'

          Did you at least take the 10 seconds to try passing the full path to Fixed_Wing.ui in loadUi('.../Fixed_Wing.ui',self), then we would be sure?

          V Offline
          V Offline
          vidyul
          wrote on 27 Feb 2024, 09:02 last edited by
          #5

          @JonB Yes I tried that too. So, what I have figured out is when I am trying to run the main file from vs code then only it gives me an error. Otherwise when I try to run through the terminal, I don't need to specify even the path or directory. Is it the issue with VS Code then?

          J 1 Reply Last reply 27 Feb 2024, 09:23
          0
          • V vidyul
            27 Feb 2024, 09:02

            @JonB Yes I tried that too. So, what I have figured out is when I am trying to run the main file from vs code then only it gives me an error. Otherwise when I try to run through the terminal, I don't need to specify even the path or directory. Is it the issue with VS Code then?

            J Offline
            J Offline
            JonB
            wrote on 27 Feb 2024, 09:23 last edited by JonB
            #6

            @vidyul
            vscode should be an environment for developing code. I cannot imagine how it could alter the behaviour of loadUi('Fixed_Wing.ui',self) or lead to error FileNotFoundError: [Errno 2] No such file or directory: 'Fixed_Wing.ui', especially if you use full path.

            Otherwise when I try to run through the terminal, I don't need to specify even the path or directory.

            How could your code, run from terminal or not, possibly know to call loadUi('Fixed_Wing.ui',self) if you never tell it to load a file named Fixed_Wing.ui? Or do you mean, you do tell it to load it but don't need to pass a path to it? Your statement is unclear.

            I don't know what is going on in your code or the way you invoke it. Let's start with: are you indeed intending to call loadUI() at runtime or are you intending to run uic (or whatever for Python) at build time to generate a .py file from your .ui file? These are two different approaches for using .ui file from Designer.

            If you are intending to use loadUI(), could you please show the actual statement with the full path in it.

            V 1 Reply Last reply 27 Feb 2024, 12:15
            0
            • J JonB
              27 Feb 2024, 09:23

              @vidyul
              vscode should be an environment for developing code. I cannot imagine how it could alter the behaviour of loadUi('Fixed_Wing.ui',self) or lead to error FileNotFoundError: [Errno 2] No such file or directory: 'Fixed_Wing.ui', especially if you use full path.

              Otherwise when I try to run through the terminal, I don't need to specify even the path or directory.

              How could your code, run from terminal or not, possibly know to call loadUi('Fixed_Wing.ui',self) if you never tell it to load a file named Fixed_Wing.ui? Or do you mean, you do tell it to load it but don't need to pass a path to it? Your statement is unclear.

              I don't know what is going on in your code or the way you invoke it. Let's start with: are you indeed intending to call loadUI() at runtime or are you intending to run uic (or whatever for Python) at build time to generate a .py file from your .ui file? These are two different approaches for using .ui file from Designer.

              If you are intending to use loadUI(), could you please show the actual statement with the full path in it.

              V Offline
              V Offline
              vidyul
              wrote on 27 Feb 2024, 12:15 last edited by
              #7

              @JonB Here is the screenshot of the error but it runs fine through terminal, the same code (loads the UI file).
              VSCODE SCREENSHOT.png

              J 1 Reply Last reply 27 Feb 2024, 12:37
              0
              • V vidyul
                27 Feb 2024, 12:15

                @JonB Here is the screenshot of the error but it runs fine through terminal, the same code (loads the UI file).
                VSCODE SCREENSHOT.png

                J Offline
                J Offline
                JonB
                wrote on 27 Feb 2024, 12:37 last edited by JonB
                #8

                @vidyul said in Unable to Open File:

                but it runs fine through terminal, the same code (loads the UI file).

                I know this. You already said it. And I previously said why this could be an issue.

                @JonB said in Unable to Open File:

                If you are intending to use loadUI(), could you please show the actual statement with the full path in it.

                Can you please read and follow instructions if you want help (at least my help). This really isn't too difficult, I already told you what the issue is likely to be. Just wasting time if you can't or won't follow the suggestion/instruction. When you have corrected it, copy & paste the line of code with loadUI() in it, not screenshot.

                V 1 Reply Last reply 28 Feb 2024, 04:11
                1
                • J JonB
                  27 Feb 2024, 12:37

                  @vidyul said in Unable to Open File:

                  but it runs fine through terminal, the same code (loads the UI file).

                  I know this. You already said it. And I previously said why this could be an issue.

                  @JonB said in Unable to Open File:

                  If you are intending to use loadUI(), could you please show the actual statement with the full path in it.

                  Can you please read and follow instructions if you want help (at least my help). This really isn't too difficult, I already told you what the issue is likely to be. Just wasting time if you can't or won't follow the suggestion/instruction. When you have corrected it, copy & paste the line of code with loadUI() in it, not screenshot.

                  V Offline
                  V Offline
                  vidyul
                  wrote on 28 Feb 2024, 04:11 last edited by
                  #9

                  @JonB your last statement seems to be rude here. What did you mean by 'atleast my help'. Maybe I miss interpret your last suggestion but this is not the way you can respond. Ofcourse we are here to help each other out isn't it?

                  J 1 Reply Last reply 28 Feb 2024, 09:28
                  0
                  • V vidyul
                    28 Feb 2024, 04:11

                    @JonB your last statement seems to be rude here. What did you mean by 'atleast my help'. Maybe I miss interpret your last suggestion but this is not the way you can respond. Ofcourse we are here to help each other out isn't it?

                    J Offline
                    J Offline
                    JonB
                    wrote on 28 Feb 2024, 09:28 last edited by JonB
                    #10

                    @vidyul
                    It expressed my frustration. I have explained that behaviour might differ between command line and vscode depending on what the current directory is. I said you must use a full path to see if that is the case. You said you did and it still does not work, so I need to see what you specified for a "full path" and hence asked:

                    If you are intending to use loadUI(), could you please show the actual statement with the full path in it.

                    You can see that italicised "with the full path in it". Because that is what we need to see.

                    You responded with (a screenshot of) code which still uses a relative path. Despite my saying that could be the problem. It seems to me that is "rude here", like you didn't bother to read my responses. If "we are here to help each other out" then you have to act on what someone responds or is asking for. "but this is not the way you can respond" applies equally to you ignoring what is asked for in your response.

                    So now, for the third time, I ask again: can you copy and paste the loadUI() you try to use which does not work and has a full path in it? The "at least my help" means: if I am to help you need to reply with that information; if you don't, that's fine, but you will need help from someone other than me.

                    V 1 Reply Last reply 13 Mar 2024, 08:36
                    0
                    • J JonB
                      28 Feb 2024, 09:28

                      @vidyul
                      It expressed my frustration. I have explained that behaviour might differ between command line and vscode depending on what the current directory is. I said you must use a full path to see if that is the case. You said you did and it still does not work, so I need to see what you specified for a "full path" and hence asked:

                      If you are intending to use loadUI(), could you please show the actual statement with the full path in it.

                      You can see that italicised "with the full path in it". Because that is what we need to see.

                      You responded with (a screenshot of) code which still uses a relative path. Despite my saying that could be the problem. It seems to me that is "rude here", like you didn't bother to read my responses. If "we are here to help each other out" then you have to act on what someone responds or is asking for. "but this is not the way you can respond" applies equally to you ignoring what is asked for in your response.

                      So now, for the third time, I ask again: can you copy and paste the loadUI() you try to use which does not work and has a full path in it? The "at least my help" means: if I am to help you need to reply with that information; if you don't, that's fine, but you will need help from someone other than me.

                      V Offline
                      V Offline
                      vidyul
                      wrote on 13 Mar 2024, 08:36 last edited by
                      #11

                      @JonB Thanks I was able to do it.
                      Actually I opened a folder in vscode and then open this file which was in another location. Hence that error message. Thank you for your help.

                      1 Reply Last reply
                      0
                      • V vidyul has marked this topic as solved on 13 Mar 2024, 08:36

                      • Login

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