I have a trouble with recipe "Creating a QGIS Plugin" from QGIS Python Cookbook by Joel Lawhead. I use QGIS 2.18, Plugin Builder and OSGeo4W Shell. I can't walk through this step:

Compile the ui file using the pyuic4 tool:

pyuic4 -o ui_myplugin.py ui_myplugin.ui

OSGeo4W Shell displays an error:

No such file or directory: "ui_myplugin.ui"

What is the cause?

  • You've got the output flag (-o) on the input file. Try pyuic4 -o ui_myplugin.ui ui_myplugin.py – user6072577 Nov 11 '16 at 8:56
  • Sorry, I had editing mistake in my question. I corrected them. In OSGeo Shell I wrote "pyuic4 -o ui_myplugin.py ui_myplugin.ui". I'll check your suggestion. – Jadwiga Trojak Nov 11 '16 at 8:59
  • 1
    Are you in the plugin repository when you execute this command? Are the files there? Use 'pwd' command for "print working directory" to check it. You should be in some repository like C:\OSGeo4W64\apps\qgis\python\plugins\nameofyourplugin if you are on Windows. – Nono Nov 11 '16 at 9:06
  • Yes, I am in the plugin folder path. There is only one ui file named myplugin_dialog_base.ui. I don't have file named ui_myplugin.ui:/ – Jadwiga Trojak Nov 11 '16 at 23:05

I ran into the same issue using QGIS 2.18, which was that I did not have a file named 'ui_myplugin.ui'. The solution was to use the 'myplugin_dialog_base.ui' file in place of the 'ui_myplugin.ui'.

So the command is:

pyuic4 –o ui_myplugin.py myplugin_dialog_base.ui

Additionally, I needed to change another step from the tutorial in order to get my plugin to work. The tutorial says to use:

pyrcc4 –o resources_rc.py resources.qrc

However, in order for QGIS to load my test plugin without any errors I needed to do:

pyrcc4 –o resources.py resources.qrc
|improve this answer|||||

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.