Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

Use pyuic5 to transfer .ui to .py, get Error in input file: not well-formed (invalid token): line 1, column 1



  • Hi everyone, I just start to use pyqt. I tried to use pyuic5 to transfer .ui to .py:

    pyuic5 -o mainwindow.py mainwindow.ui
    

    but it got error:

    Error in input file: not well-formed (invalid token): line 1, column 1
    

    the head part of the ui file is:

    <?xml version="1.0" encoding="UTF-8"?>
    <ui version="4.0">
     <class>Form</class>
     <widget class="QWidget" name="Form">
      <property name="geometry"> 
    ...
    

    I have installed pyqt5, pyqt5-tools. I searched online but not find solution yet. Please help me! Thanks in advance!


  • Lifetime Qt Champion

    Hi,

    How did you create that .ui file ?
    What was the version of the tool ?



  • Hi @SGaist, I used designer.exe in pyqt5-tools to create .ui file. The pyqt5 version is 5.13.0, qt5 version is 5.13.0, python version is 3.6.4



  • @SoleyRan
    It seems that error message can occur even if the actual error is late in the file. You could make a change in the Designer to force resave and check again. What about reading the .ui file into an XML editor to see if that complains about it, with a more specific error?



  • @JonB Thank you for the reply. I modified the .ui file but it still occurred error. I thought it might because of the designer version problem, so I changed to use Qt creator to generate .ui file, finally it worked. It was weird because my Qt version is also 5.13.0, the same as pyqt5-tools...


  • Lifetime Qt Champion

    Do you have several versions installed ?


Log in to reply