How to compile QtDesigner user interface (.ui) and resource (.qrc) files with QGIS 3 on Windows?

You need set PyQT5 environments. This is my scripts for compile QGIS 3 Plugins and have 3 complementary bats.

compile_ui.bat

@ECHO OFF

set OSGEO4W_ROOT=D:\OSGeo4W64

set PATH=%OSGEO4W_ROOT%\bin;%PATH%
set PATH=%PATH%;%OSGEO4W_ROOT%\apps\qgis\bin

@echo off
call "%OSGEO4W_ROOT%\bin\o4w_env.bat"
call "%OSGEO4W_ROOT%\bin\qt5_env.bat"
call "%OSGEO4W_ROOT%\bin\py3_env.bat"
@echo off
path %OSGEO4W_ROOT%\apps\qgis-dev\bin;%OSGEO4W_ROOT%\apps\grass\grass-7.2.2\lib;%OSGEO4W_ROOT%\apps\grass\grass-7.2.2\bin;%PATH%

cd /d %~dp0

@ECHO ON
::Ui Compilation
call pyuic5 dialog.ui -o gui\generated\ui_dialog.py          

::Resources
call pyrcc5 ui\resources.qrc -o gui\generated\resources_rc.py

@ECHO OFF
GOTO END

:ERROR
   echo "Failed!"
   set ERRORLEVEL=%ERRORLEVEL%
   pause

:END
@ECHO ON

You only need change set OSGEO4W_ROOT=D:\OSGeo4W64 for set OSGEO4W_ROOT="C:\Program Files\QGIS 2.99", or something like that,

Try using this .bat

Note: this bat is in the same folder as the plugin

Note 2 : For import import resources_rc need this trick

call pyuic5 --import-from <package-name>.gui.generated dialog.ui -o gui\generated\ui_dialog.py`

this path probably change in other plugin. pyuic5

@sigeal soluton for Note 2 :

call pyuic5 dockwidget_base.ui --from-imports -o dockwidget_base.py

I hope it helps


After having found out everything about the environment variables and knowing what I was searching for, I found the file /osgeo4w_root/bin/python-qgis-dev.bat

When called from the active osgeo4w shell, it sets all the env. variables by calling the corresponding .bat files (as suggested by Francisco)!