cx_Freeze 的 Pyserial 运行时错误
Pyserial runtime error with cx_Freeze
我正在尝试在 Raspberry Pi 上使用 cx_Freeze 制作可执行文件 3. 代码全部编译没有问题,但我收到 运行 时间错误:
import serial
File "/home/pi/.virtualenvs/cv/local/lib/python2.7/site-packages/serial/__init__.py, line 12 in <module> standard_library.install_aliases()
File "/home/pi/.virtualenvs/cv/local/lib/python2.7/site-packages/future/standard_library/__init__.py", line 487, in install_aliases
from future.moves.test import support
File "/usr/lib/python2.7/test/test_support.py", line 642, in <module>
character.encode(sys.getfilesystemencoding())\
TypeError: encode() argument 1 must be string, not None
当 运行 来自源代码时,代码工作正常。该错误仅在 运行 编译版本时显示。
有人有什么想法吗?提前致谢。
此问题与 sys.getfilesystemencoding()
返回 None
有关,如下所述:
https://github.com/anthony-tuininga/cx_Freeze/issues/323
我尝试了建议的回滚到版本 5.0.2、5.0.1、5.0,但这些只是引发了不同的问题。
我已经通过将 /usr/lib/python2.7/test/test_support.py
第 642 行的代码更改为硬编码字符串 character.encode('UTF-8').decode('UTF-8')
来破解此问题
虽然我现在可以正常工作,但如果有人有合适的解决方案,那会很好吗?
我正在尝试在 Raspberry Pi 上使用 cx_Freeze 制作可执行文件 3. 代码全部编译没有问题,但我收到 运行 时间错误:
import serial
File "/home/pi/.virtualenvs/cv/local/lib/python2.7/site-packages/serial/__init__.py, line 12 in <module> standard_library.install_aliases()
File "/home/pi/.virtualenvs/cv/local/lib/python2.7/site-packages/future/standard_library/__init__.py", line 487, in install_aliases
from future.moves.test import support
File "/usr/lib/python2.7/test/test_support.py", line 642, in <module>
character.encode(sys.getfilesystemencoding())\
TypeError: encode() argument 1 must be string, not None
当 运行 来自源代码时,代码工作正常。该错误仅在 运行 编译版本时显示。
有人有什么想法吗?提前致谢。
此问题与 sys.getfilesystemencoding()
返回 None
有关,如下所述:
https://github.com/anthony-tuininga/cx_Freeze/issues/323
我尝试了建议的回滚到版本 5.0.2、5.0.1、5.0,但这些只是引发了不同的问题。
我已经通过将 /usr/lib/python2.7/test/test_support.py
第 642 行的代码更改为硬编码字符串 character.encode('UTF-8').decode('UTF-8')
虽然我现在可以正常工作,但如果有人有合适的解决方案,那会很好吗?