[PyQt] Python 3 import error

Nathan Weston nathan at genarts.com
Thu Dec 2 22:30:10 GMT 2010


On 12/2/2010 5:11 PM, Thorsten Kampe wrote:
> * Hans-Peter Jansen (Thu, 2 Dec 2010 20:16:13 +0100)
>>>> sip.setapi('QVariant', 2)
>
> Unfortunately, when I set "sip.setapi('QVariant', 2)" then I can't run
> the application as stand-alone Pyinstaller[1] executable (neither under
> Windows nor Linux):
> ValueError: API 'QVariant' has already been set to version 1
>

PyInstaller somehow ends up importing PyQt before your code runs, so the 
API version is implicitly set to 1. You can work around this by editing 
support/rthooks/pyi_rth_qt4plugins.py and adding these lines before the 
import of QtCore:

import sip
sip.setapi('QVariant', 2)

-- 
. . . . . . . . . . . . . . . . . . . . . . . . .
Nathan Weston                   nathan at genarts.com
GenArts, Inc.                   Tel: 617-492-2888
955 Mass. Ave                   Fax: 617-492-2852
Cambridge, MA 02139 USA         www.genarts.com


More information about the PyQt mailing list