4

I am trying to convert ui file created by QTDesigner to py file. but i get the error: pyuic5 is not recognized as an internal or external command. I use anaconda 3, and tried all suggestions here:

C:/Program is not recognized ...related to pyuic5.

and i have seen here:

'Pyuic4' is not recognized as an internal external command.

keramat
  • 4,328
  • 6
  • 25
  • 38

9 Answers9

5

You need to first install pyqt5-tools

Via cmd writes Notice: python should be in windows environment variables :

pip install pyqt5-tools

Then you can use pyuic5

pyuic5 -x yourform.ui -o file.py
lobeg25
  • 9
  • 3
3

for any one has this problem: the key is that in anaconda3 pyuic5.bat is in:

Anaconda3\Library\bin

also the Designer is here.

so in cmd you must first cd to:

Anaconda\Library\bin\

then:

pyuic5.bat -x filename.ui -o filename.py
keramat
  • 4,328
  • 6
  • 25
  • 38
1

go to this path in your anaconda installation

C:\Program Files\Anaconda3\Library\bin

edit the pyuic5.bat and add the "" to the batch so it should be like this:

@"C:/Program Files/Anaconda3\python.exe" .....

then use this code to convert your file:

pyuic5 -x example.ui -o example.py
Logixor
  • 69
  • 1
  • 12
Bassem Shahin
  • 656
  • 7
  • 13
  • 2
    but I did not install Anaconda, because the pyuic5 is supposed to be bundled with pyQt5, which I installed, so the question remains, once the venv is accessed from the CMD shell, why pyuic5 cannot be resolved by Windows? – Echeban Nov 09 '19 at 20:43
  • i simply installed pyqt5 using `pip install PyQt5` and pyuic5 command is not working. but i found *pyuic.py* in "...Python38\Lib\site-packages\PyQt5\uic" i runned it and it also give error ***from .driver import Driver ImportError: attempted relative import with no known parent package*** – ghost21blade Jan 05 '22 at 13:25
0
  1. Create form by using Qtdesigner
  2. Save the file as filename.ui in Anaconda3\Library\ bin location
  3. Open command prompt
  4. Make the path as C:\Users\SGU\anaconda3\Library\bin>
  5. Then add the command to convert UI file to PY file as follows C:\Users\SGU\anaconda3\Library\bin>pyuic5 –x filename.ui -o filename.py
  6. Filename.py file created at location C:\Users\SGU\anaconda3\Library\bin>
  7. Then Run the code by using Pycharm by opening the filename.py file to get the filename.ui file (Desined Window) will arrive at the output screen.
0

You should install PyQt5 first. As I was trying pyuic4 and it showed an error. Then I saw that PyQt4 is not installed. So I tried pyuic5. You can Install PyQt5 with the 'pip install pyqt5' command.

0

Here is my solution:

Before wasting my time on such an annoying problem I used the the linux subsystem ubuntu which I had installed before. There I simply tiped in:

pip install pyqt5-tools

copied the ui file to the current folder, typed

pyuic5 -x FILENAME.ui -o FILENAME.py

and copied the output file back.

If you have problems with showing linux directory, you should try to type in

\\wsl$

to file explorer in windows. Sorry for my bad english. This is just a tip from my side which works kind of quick without reading the whole stackoverflow. :)

mÄxZ
  • 1
  • 1
0

I could fix this problem by adding the path of Scripts folder containing pyuic5.exe to the System Environment Variables*.

For my case: C:\Users\My PC\AppData\Roaming\Python\Python311\Scripts

-1

For me, moving the pyuic5 application from the path in which it was before to the path my file was.

Like before pyuic5 application was in the path:
C:\Users\ASUS\AppData\Roaming\Python\Python39\Scripts
And then I moved it to the path:
C:\Users\ASUS\Desktop\Jarvis-everything\Github Jarvis\Jarvis2\Code
Where my file was, then it worked.

For you, it might be different but it is easy to find. Just open cmd, type pip install pyqt5 then enter.
You will see that it shows "Requirement already satisfied"(if you have already installed) on the same line you will find your path where it is installed.

There, find the pyuic5 application and move it to the path where the file you want to convert is present.

David Buck
  • 3,752
  • 35
  • 31
  • 35
  • 1
    An answer isn't better just because you make it entirely bold, it's just harder to read. Especially if you don't use line breaks, paragraphs or code formatting. – David Buck Oct 29 '21 at 11:58
-1

You should right the path of pyuic.exe then "-x" then the path of the "file.ui" and then "-o" and the same path of the "file.py"

  • As it’s currently written, your answer is unclear. Please [edit] to add additional details that will help others understand how this addresses the question asked. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Community Apr 21 '22 at 01:26