python 打包后运行报错 [6464] Failed to execute script 'update_servers' due to unhandled exception!

报错信息:

Traceback (most recent call last):
File "update_servers.py", line 17, in <module>
File "<frozen importlib._bootstrap>", line 983, in _find_and_load
File "<frozen importlib._bootstrap>", line 967, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 677, in _load_unlocked
File "PyInstaller\loader\pyimod03_importers.py", line 495, in exec_module
File "update_tool\qflash_upgrade.py", line 9, in <module>
File "<frozen importlib._bootstrap>", line 983, in _find_and_load
File "<frozen importlib._bootstrap>", line 967, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 677, in _load_unlocked
File "PyInstaller\loader\pyimod03_importers.py", line 495, in exec_module
File "update_tool\Upgrade.py", line 10, in <module>
File "<frozen importlib._bootstrap>", line 983, in _find_and_load
File "<frozen importlib._bootstrap>", line 967, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 677, in _load_unlocked
File "PyInstaller\loader\pyimod03_importers.py", line 495, in exec_module
File "update_tool\QFlashHandle.py", line 15, in <module>
File "<frozen importlib._bootstrap>", line 983, in _find_and_load
File "<frozen importlib._bootstrap>", line 967, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 677, in _load_unlocked
File "PyInstaller\loader\pyimod03_importers.py", line 495, in exec_module
File "pyautogui\__init__.py", line 183, in <module>
File "<frozen importlib._bootstrap>", line 983, in _find_and_load
File "<frozen importlib._bootstrap>", line 967, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 677, in _load_unlocked
File "PyInstaller\loader\pyimod03_importers.py", line 495, in exec_module
File "pyscreeze\__init__.py", line 45, in <module>
File "<frozen importlib._bootstrap>", line 983, in _find_and_load
File "<frozen importlib._bootstrap>", line 967, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 677, in _load_unlocked
File "PyInstaller\loader\pyimod03_importers.py", line 495, in exec_module
File "cv2\__init__.py", line 181, in <module>
File "cv2\__init__.py", line 111, in bootstrap
File "cv2\__init__.py", line 106, in load_first_config
File "cv2\load_config_py3.py", line 8, in exec_file_wrapper
UnicodeDecodeError: 'gbk' codec can't decode byte 0xb9 in position 27: illegal multibyte sequence
[6464] Failed to execute script 'update_servers' due to unhandled exception!

解决方法(可依次尝试):

1.重装cv2。(这是回答比较多的,多数情况有用)
先pip unintall opencv-python ,再pip intall opencv-python

2.降低cv2版本。
pyinstaller和cv2的版本存在兼容问题。本人用的pyinstaller是4.7(python3.7.2),cv2是4.7.0.72,结果出错,把cv2版本降低到4.5.1.48再打包,就不报错了。

 

posted @ 2023-06-26 10:59  乖乖楠  阅读(409)  评论(0编辑  收藏  举报