Search code examples
pythonpyqtanacondaqt-designerpyuic

Convert .ui file to .py file using Anaconda


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!


Solution

  • 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