Convert .ui file to .py file using Anaconda

Question:

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:Python36Libsite-packagesPyQT5uic)

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!

Asked By: a.ras2002

||

Answers:

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.

Answered By: kenjii himura

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
Answered By: ILYAS_Kerbal

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:ProgramDataAnaconda3python -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.

Answered By: crx

This one works for me on my Windows 10 machine

C:ProgramDataAnaconda3python -m PyQt5.uic.pyuic -x "C:dialog1.ui" -o "C:dialog1.py"
Answered By: karthi k

C:ProgramDataAnaconda3python -m PyQt5.uic.pyuic -x "C:dialog1.ui" -o "C:dialog1.py"

works

Answered By: GonzaloV

On my side I opened the cmd windows from ananconda directly. Navigated to the folder (with cd) containing the .ui file. Then I used the command:

C:.... python -m PyQt5.uic.pyuic -x "test.ui" -o "test.py"

Answered By: Ju Mo