Convert .ui file to .py file using Anaconda

16,792

Solution 1

Personally, I do it manually Open the terminal and navigate to the directory containing your .ui file.

For PyQt5:

pyuic5 -x example.ui -o example.py

for PyQt4:

pyuic4 -x example.ui -o example.py

Solution 2

I had the same Error. I guess the anwers above refer to Linux?

On Windows 7 entering the following line in CMD worked for me:

C:\ProgramData\Anaconda3\python -m PyQt5.uic.pyuic -x "C:\dialog1.ui" -o "C:\dialog1.py"

Notice that there is no path of pyuic. It is called as a class member.

Solution 3

To convert .ui to .py, I do the following :

I use python 3.4 QT5, so the correct command is:

pyuic5 -x gui.ui -o gui.py

Where gui is your file name.

Solution 4

This one works for me on my Windows 10 machine

C:\ProgramData\Anaconda3\python -m PyQt5.uic.pyuic -x "C:\dialog1.ui" -o "C:\dialog1.py"
Share:
16,792

Related videos on Youtube

a.ras2002
Author by

a.ras2002

Updated on June 04, 2022

Comments

  • a.ras2002
    a.ras2002 about 2 years

    Hi maybe this is a stupid question but I can't find the error or what should I do to do this...

    I have a .ui file with my GUI designed on QT Designer, and I want to use it with Python. I have installed Anaconda 2 (Python 2.7) and Python 3.6, but when I run the command in the folder where pyuic.py is (C:\Python36\Lib\site-packages\PyQT5\uic)

    python pyuic.py -o mainwindow.ui 
    

    I have the following error

    Traceback (most recent call last):
    File "pyuic.py", line 28, in <module>
    from .driver import Driver
    ModuleNotFoundError: No module named '__main__.driver'; '__main__' is not a package
    

    Anyone could tell me why and how can I solve it??

    Thanks in advance!