wxPython-4.0.1
PyInstaller: 3.3.1
Python: 2.7.14
Windows-10-10.0.17134
``
**Run the command****
pyinstaller helloworld**.py
Add Chinese path
..\test\dist\helloworld\ → ..test\dist\helloworld_测试\
``
**Run**
G:\python_project\python\gui_wxpython\test\dist\helloworld_测试>helloworld.exe
Traceback (most recent call last):
File “helloworld.py”, line 13, in
File “site-packages\wx\core.py”, line 2060, in init
UnicodeDecodeError: ‘utf8’ codec can’t decode byte 0xb2 in position 59: invalid start byte
[11712] Failed to execute script helloworld
G:\python_project\python\gui_wxpython\test\dist\helloworld_测试>
``
Can you help me? Thank you
Robin
June 23, 2018, 4:58pm
2
On Saturday, June 23, 2018 at 8:34:18 AM UTC-7, Love is going on li wrote:
G:\python_project\python\gui_wxpython\test\dist\helloworld_测试>helloworld.exe
``
Traceback (most recent call last):
File “helloworld.py”, line 13, in
File “site-packages\wx\core.py”, line 2060, in init
UnicodeDecodeError: ‘utf8’ codec can’t decode byte 0xb2 in position 59: invalid start byte
[11712] Failed to execute script helloworld
G:\python_project\python\gui_wxpython\test\dist\helloworld_测试>
``
Can you help me? Thank you
That line is:
wx.StandardPaths.Get().SetInstallPrefix(_sys.prefix)
SetInstallPrefix expects to get a unicode string, or something that can be converted to unicode using the utf-8 encoding. Since you are using Python2 then sys.prefix is likely a non-unicode string and it is probably encoded using the filesystem’s default encoding, which isn’t utf-8. Please try replacing that line with this code and let us know if that takes care of the problem for you.
prefix = _sys.prefix
if isinstance(prefix, (bytes, bytearray)):
prefix = prefix.decode(_sys.getfilesystemencoding())
wx.StandardPaths.Get().SetInstallPrefix(prefix)
···
–
Robin