Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Python error: #2

Closed
Tele-Pet opened this issue Aug 5, 2015 · 9 comments
Closed

Python error: #2

Tele-Pet opened this issue Aug 5, 2015 · 9 comments

Comments

@Tele-Pet
Copy link

Tele-Pet commented Aug 5, 2015

I copied the qgis-cartogram-develop folder into .qgis2/plugins/ and get the following error upon starting up QGIS 2.8:

Couldn't load plugin qgis-cartogram-develop due to an error when calling
its classFactory() method

Full error message:

Traceback (most recent call last):
File "/Applications/QGIS_28/QGIS.app/Contents/MacOS/../Resources/python/qgis/utils.py", line 219, in startPlugin
plugins[packageName] = package.classFactory(iface)
File "/Users/myUserName/.qgis2/python/plugins/qgis-cartogram-develop/init.py", line 7, in classFactory
from .cartogram import Cartogram
File "/Applications/QGIS_28/QGIS.app/Contents/MacOS/../Resources/python/qgis/utils.py", line 478, in _import
mod = _builtin_import(name, globals, locals, fromlist, level)
File "/Users/myUserName/.qgis2/python/plugins/qgis-cartogram-develop/cartogram.py", line 10, in
from cartogram_dialog import CartogramDialog
File "/Applications/QGIS_28/QGIS.app/Contents/MacOS/../Resources/python/qgis/utils.py", line 478, in _import
mod = _builtin_import(name, globals, locals, fromlist, level)
File "/Users/myUserName/.qgis2/python/plugins/qgis-cartogram-develop/cartogram_dialog.py", line 6, in
os.path.dirname(file), 'cartogram_dialog_base.ui'))
File "/Applications/QGIS_28/QGIS.app/Contents/MacOS/../Resources/python/PyQt4/uic/init.py", line 213, in loadUiType
exec(code_string.getvalue(), ui_globals)
File "", line 66, in
File "/Applications/QGIS_28/QGIS.app/Contents/MacOS/../Resources/python/qgis/utils.py", line 478, in _import
mod = _builtin_import(name, globals, locals, fromlist, level)
ImportError: No module named qgsfieldcombobox

In Plugins Manager I can see the plugin, but it is highlighted red, with the following error:

This plugin is broken
invalid syntax

@wvcpw
Copy link
Contributor

wvcpw commented Aug 5, 2015

Same error in 2.10 Pisa

@anitagraser
Copy link

The issue seems cause by custom widgets which are not loaded correctly.

I've fixed it locally by compiling the .ui file manually

C:\Users\anita\.qgis2\python\plugins\qgis-cartogram-develop>pyuic4 -o cartogram_dialog_base.py cartogram_dialog_base.ui

and changing cartogram_dialog.py to

import os
from PyQt4 import QtGui, uic
from cartogram_dialog_base import Ui_CartogramDialogBase

class CartogramDialog(QtGui.QDialog, Ui_CartogramDialogBase):
    def __init__(self, parent=None):
        """Constructor. Sets up the user interface from QT Designer."""
        super(CartogramDialog, self).__init__(parent)
        self.setupUi(self)

and the last lines of cartogram_dialog_base.py to

from qgis.gui import QgsFieldComboBox
from qgis.gui import QgsMapLayerComboBox

@Tele-Pet
Copy link
Author

Tele-Pet commented Aug 5, 2015

Thanks @anitagraser. I didn't have PyQt4 installed, but once I did, I was able to make the changes your noted and am able to run the plugin now.

@Tele-Pet Tele-Pet closed this as completed Aug 5, 2015
@anitagraser
Copy link

Maybe reopen the issue. It really should be fixed so that users don't have to mess around with the code.

@wulff
Copy link
Member

wulff commented Aug 6, 2015

Thanks for reporting this issue.

So far, I have only tested the beta on Linux, but I'll try and get it working on Mac and Windows as well.

@wulff wulff reopened this Aug 6, 2015
@wulff
Copy link
Member

wulff commented Aug 6, 2015

I have modified my makefile to compile the form code (as per Anita's example above) instead of using my own custom code.

The latest version of the plugin has been tested in 2.10 on Linux and 2.8 on Mac OS and seems to work as intended.

@wvcpw
Copy link
Contributor

wvcpw commented Aug 6, 2015

Now works on Windows in 2.10 as well.

@Tele-Pet
Copy link
Author

Tele-Pet commented Aug 6, 2015

Now working for me on Mac, Yosemite 10.10.4, including QGIS Pisa(2.10.1) and Wein(2.8.2).

@wulff
Copy link
Member

wulff commented Aug 7, 2015

@Tele-Pet good to hear!

I have submitted version 1.0 of the plugin to the plugin repository.

@wulff wulff closed this as completed Aug 7, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants