Sunday 20 September 2015

qgis - Plugins crashing with "No module named qgsprojectionselectionwidget" in Windows?


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?




Answer



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


Please open your .ui file and find lines:



QgsProjectionSelectionWidget
QWidget
qgsprojectionselectionwidget.h



Then in your header tag change to:




QgsProjectionSelectionWidget
QWidget
qgis.gui



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


No comments:

Post a Comment

arcpy - Changing output name when exporting data driven pages to JPG?

Is there a way to save the output JPG, changing the output file name to the page name, instead of page number? I mean changing the script fo...