arminstraub / krop

A simple graphical tool to crop the pages of PDF files, written in Python/Qt
http://arminstraub.com/software/krop
GNU General Public License v3.0
122 stars 13 forks source link

Fix compatibility with PyQt5 >=5.11 and PyQt4 >= 4.12.2 #20

Closed heirecka closed 4 years ago

heirecka commented 5 years ago

Since those two versions PyQt uses a private copy of the sip module. This results in an error when trying to start krop: "ModuleNotFoundError: No module named 'sip'". According to the documentation [1][2] including any PyQt module before importing sip works with both versions.

[1] https://www.riverbankcomputing.com/static/Docs/PyQt5/incompatibilities.html#pyqt-v5-11 [2] https://www.riverbankcomputing.com/static/Docs/PyQt4/incompatibilities.html#pyqt-v4-12-2

arminstraub commented 4 years ago

Thank you! The patch didn't work on my old python2 machine still running Ubuntu 14.04 (ValueError: API 'QString' has already been set to version 1), so I moved the code involving sip (which is only needed in the case of python2) to a separate block at the beginning. I hope this runs on all systems (I ran a quick test in Ubuntu 20.04 in a virtual machine). Please forgive the terrible delay!