8

My Python QGIS plugin works on Ubuntu (at least for me, and all fatal bugs reported so far are solved), but when I run it on QGIS installed from the official 2.10.1 64-bit installer for Windows (on Windows 7 64-bit), I can't install it due to following error:

This plugin is broken
No module named qgsprojectionselectionwidget

Another user reported it this problem as well. but with another error message (I don't know which operation system and architecture does he have, but I'd guess Windows and 64-bit EDIT: I guessed wrong, he has Mac OS X):

This plugin is broken
No module named qgsmaplayercombobox

Both refer to widgets in the GUI form, which I built through Qt Designer in Ubuntu. Qt Designer is packed with QGIS installer for Windows as well and claims to contain the same QGIS custom widgets, so the problem shouldn't be in those widgets missing, and QGIS should recognize them - but it doesn't.

So how to fix it? My plugin is still experimental, so I can just add "sorry, doesn't work under Windows" to the metadata, but it's not a real solution.

EDIT: the same behavior confirmed on 32-bit version too.

Now I found a good hint in comment to this answer: use os.path.join to make the paths cross-platform. This is easy for the few hardcoded paths I have, but the errors seems to suggest the problem is deeper, perhaps even in Qt. How can I handle this problem in my plugin without tweaking anything else?

20

Probably your QGIS is trying to import your widget from .h file like in c++.

Please open your .ui file and find lines:

<customwidget>
   <class>QgsProjectionSelectionWidget</class>
   <extends>QWidget</extends>
   <header>qgsprojectionselectionwidget.h</header>
  </customwidget>

Then in your header tag change to:

<customwidget>
   <class>QgsProjectionSelectionWidget</class>
   <extends>QWidget</extends>
   <header>qgis.gui</header>
  </customwidget>

Change the same tag for all your widgets with error (qgsmaplayercombobox etc.).

0

@dmh126's answer is good. Especially, if you are work with pyqt - pyqgis, you should write from qgis._gui import * instead of import QgsProjectionSelectionWidget.

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.