QGIS Python Issue – ‘Pyrcc5’ ImportError: DLL Load Failed: The Specified Module Could Not Be Found

pyqgispythonqgisqgis-plugins

I'm creating a plugin on QGIS for which I'm trying to compile the resources so I can start using it.

I'm following this video: https://www.youtube.com/watch?v=GccxvQ1ypbc roughly around the 3:45 mark.

Plugin is created then I get another message tied to pyrcc5 just like in the video.

enter image description here

I open OSGeo4W Shell in admin mode, I go straight to my plugin's directory and I get this error upon following the same steps the person in the video is doing:

enter image description here

Le module spécifié est introuvable means The specified module could not be found

Please help, I have no clue what could be the issue. This is what my plugin directory upon creating looks like:

enter image description here

Best Answer

First of all, in:

Control Panel\Appearance and Personalization

click in View Tab for uncheck "Hide extensions for known file types" option. Afterward, create a Windows Batch file (.bat extension) with the following content:

@echo off
call "C:\Program Files\QGIS 3.16\bin\o4w_env.bat"
call "C:\Program Files\QGIS 3.16\bin\qt5_env.bat"
call "C:\Program Files\QGIS 3.16\bin\py3_env.bat"

@echo on
pyrcc5 -o resources.py resources.qrc

and save it inside your plugin as compile.bat. In my example plugin (fortextthings), it was saved in following path:

C:\Users\zeito\AppData\Roaming\QGIS\QGIS3\profiles\default\python\plugins\fortextthings

Open a Command prompt and type your equivalent following commands (as follows, it has my plugin path):

cd C:\Users\zeito\AppData\Roaming\QGIS\QGIS3\profiles\default\python\plugins\fortextthings [Enter]
compile.bat [Enter]

As result, it was printed following text without any error message:

C:\Users\zeito\AppData\Roaming\QGIS\QGIS3\profiles\default\python\plugins\fortextthings>pyrcc5 -o resources.py resources.qrc

and, afterward, my plugin was activated in "Manage and Install plugins" menu without any problem.