dgoedkoop / joinmultiplelines

QGis Join Multiple Lines
BSD 2-Clause "Simplified" License
10 stars 5 forks source link

Qgis - PyQt5- Backwards Incompatible Changes ? #6

Open alpterlab opened 4 years ago

alpterlab commented 4 years ago

Hello @dgoedkoop @pcav I am having issues with the plugin on this error.... reffering to python incompatibilty ? I wondering if it is a personal installation problem or just an issue connected to Backwards Incompatible Changes ImportError: PyQt4 classes cannot be imported in QGIS 3.x. Use PyQt5 or the version independent qgis.PyQt import instead.

ImportError: PyQt4 classes cannot be imported in QGIS 3.x. Use PyQt5 or the version independent qgis.PyQt import instead. Traceback (most recent call last): File "C:/OSGEO4~1/apps/qgis-ltr/./python\qgis\utils.py", line 334, in _startPlugin plugins[packageName] = package.classFactory(iface) File "C:/Users/info/AppData/Roaming/QGIS/QGIS3\profiles\default/python/plugins\joinmultiplelines__init__.py", line 3, in classFactory from .joinmultiplelines import joinmultiplelines File "C:/OSGEO4~1/apps/qgis-ltr/./python\qgis\utils.py", line 744, in _import mod = _builtin_import(name, globals, locals, fromlist, level) File "C:/Users/info/AppData/Roaming/QGIS/QGIS3\profiles\default/python/plugins\joinmultiplelines\joinmultiplelines.py", line 61, in import resources File "C:/OSGEO4~1/apps/qgis-ltr/./python\qgis\utils.py", line 744, in _import mod = _builtin_import(name, globals, locals, fromlist, level) File "C:/Users/info/AppData/Roaming/QGIS/QGIS3\profiles\default/python/plugins\go2mapillary\resources.py", line 10, in from PyQt4 import QtCore File "C:/OSGEO4~1/apps/qgis-ltr/./python\qgis\utils.py", line 742, in _import raise ImportError(msg) ImportError: PyQt4 classes cannot be imported in QGIS 3.x. Use PyQt5 or the version independent qgis.PyQt import instead.

Versione Python: 3.7.0 (v3.7.0:1bf9cc5093, Jun 27 2018, 04:59:51) [MSC v.1914 64 bit (AMD64)] Versione di QGIS: 3.10.3-A Coruña A Coruña, 0e1f846438

alpterlab commented 4 years ago

It seems a problem of my local installation.... :- (

alpterlab commented 4 years ago

I found the problem.. it is connected to the installation of another plugin... go2mapillary Whenever I do install it... this pugin "joinmultiplelines" starts not to function anymore with the above error.....

enricofer commented 4 years ago

@alpterlab I'm the developer of go2mapillary. having a look to exception trace it appear that is thrown by resources.py of mapillary plugin. but that file is non longer needed and should be deleted manually. Even if I will soon release a new version deletin resurces files, @dgoedkoop I found very strange that your plugin import resources https://github.com/dgoedkoop/joinmultiplelines/blob/f9c201e87357b2237abea99e4de9f8b93908b798/joinmultiplelines.py#L61 without using it in the code and without having resources.py in your path. I think there is some sys.path issue. You try to import resources without any need and I left an old version of the file forgetting to delete it.

dgoedkoop commented 4 years ago

The resource file is used to display the icon on the toolbar, in this line: https://github.com/dgoedkoop/joinmultiplelines/blob/f9c201e87357b2237abea99e4de9f8b93908b798/joinmultiplelines.py#L69

I think I could make this code more robust by using sys.path.insert(0, ...) instead of sys.path.append(...), before doing import resources

enricofer commented 4 years ago

Why not simply get rid of resources and load directly the icon: self.action = QAction(QIcon(os.path.join(os.path.dirname(__file__),"icon.png")), "Join multiple lines", self.iface.mainWindow()) and remove sys.path.append(os.path.dirname(__file__)) ? I think that the issue is caused by sys.path runtime mismatch.