[PyQt] Unicode errors with PyQt5?

Chris Pezley chris at pezley.net
Thu Sep 6 06:26:14 BST 2018


Hi,

try setting the sip api to use version 2 at the beginning of your program:

import sip
sip.setapi('QDate', 2)
sip.setapi('QDateTime', 2)
sip.setapi('QString', 2)
sip.setapi('QTextStream', 2)
sip.setapi('QTime', 2)
sip.setapi('QUrl', 2)
sip.setapi('QVariant', 2)

This will make Qt give you unicode strings and get rid of QVariants in 
lieu of native python types. Unfortunately the documentation for this is 
a bit lacking 
(http://pyqt.sourceforge.net/Docs/sip4/python_api.html?highlight=setapi), 
so it is hard to find the api options.

Chris


On 08/27/2018 06:21 PM, Jones, Bryan wrote:
> All,
>
> It seems that PyQt5 doesn't handle Unicode library paths correctly. 
> (Of course, this could be an underlying Qt5 problem). Any advice/pointers?
>
> (venv) F:\tmp\中文路径>python
> Python 3.6.1 (v3.6.1:69c0db5, Mar 21 2017, 18:41:36) [MSC v.1900 64 
> bit (AMD64)] on win32
> Type "help", "copyright", "credits" or "license" for more information.
> >>> from PyQt5.QtCore import QLibraryInfo
> >>> QLibraryInfo.location(QLibraryInfo.LibrariesPath)
> 'F:/tmp/????/venv/lib/site-packages/PyQt5/Qt/lib'
> >>> import sys
> >>> sys.path
> ['', 'F:\\tmp\\中文路径\\venv\\Scripts\\python36.zip', 
> 'F:\\Downloads\\Python36-64\\DLLs', 'F:\\Downloads\\Python36-64\\lib', 
> 'F:\\Downloads\\Python36-64', 'F:\\tmp\\中文路径\\venv', 
> 'F:\\tmp\\中文路径\\venv\\lib\\site-packages']
> >>> from PyQt5.QtCore import QT_VERSION_STR, PYQT_VERSION_STR
> >>> print(QT_VERSION_STR, PYQT_VERSION_STR)
> 5.11.1 5.11.2
>
> (Credit goes to DionSun, reported at 
> https://github.com/pyinstaller/pyinstaller/issues/3696)
>
> Bryan
> -- 
> Bryan A. Jones, Ph.D.
> Associate Professor
> Department of Electrical and Computer Engineering
> 231 Simrall / PO Box 9571
> Mississippi State University
> Mississippi State, MS 39762
> http://www.ece.msstate.edu/~bjones <http://www.ece.msstate.edu/%7Ebjones>
> bjones AT ece DOT msstate DOT edu
> voice 662-325-3149
> fax 662-325-2298
>
> Our Master, Jesus Christ, is on his way. He'll show up right on
> time, his arrival guaranteed by the Blessed and Undisputed Ruler,
> High King, High God.
> - 1 Tim. 6:14b-15 (The Message)
>
>
> _______________________________________________
> PyQt mailing list    PyQt at riverbankcomputing.com
> https://www.riverbankcomputing.com/mailman/listinfo/pyqt

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://www.riverbankcomputing.com/pipermail/pyqt/attachments/20180906/96d26456/attachment.html>


More information about the PyQt mailing list