gpt4 book ai didi

python - 使用pyinstaller时出错: UnicodeDecodeError: 'utf-8' codec can't decode byte 0xff

转载 作者:太空狗 更新时间:2023-10-29 20:13:23 25 4
gpt4 key购买 nike

我在使用 pyinstaller 编译 PyQt 代码时遇到问题。

我用这一行来编译:

c:\Anaconda3\Scripts\pyinstaller.exe -y -F --distpath="." MyQt.py

然后我收到此错误消息:

      File "c:\anaconda36bis\lib\site-packages\PyInstaller\hooks\hook-zmq.py", line
18, in <module>
hiddenimports.extend(collect_submodules('zmq.backend'))
File "c:\anaconda36bis\lib\site-packages\PyInstaller\utils\hooks\__init__.py",
line 619, in collect_submodules
repr(pkg_dir), package))
File "c:\anaconda36bis\lib\site-packages\PyInstaller\utils\hooks\__init__.py",
line 90, in exec_statement
return __exec_python_cmd(cmd)
File "c:\anaconda36bis\lib\site-packages\PyInstaller\utils\hooks\__init__.py",
line 77, in __exec_python_cmd
txt = exec_python(*cmd, env=pp_env)
File "c:\anaconda36bis\lib\site-packages\PyInstaller\compat.py", line 562, in
exec_python
return exec_command(*cmdargs, **kwargs)
File "c:\anaconda36bis\lib\site-packages\PyInstaller\compat.py", line 369, in
exec_command
out = out.decode(encoding)
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xff in position 152: invali
d start byte

我不清楚错误消息,我不明白为什么会这样。

pyinstaller 是否有可能尝试使用不兼容的模块?我在我的脚本中使用这些:

# -*- coding: utf-8 -*-
from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
from __future__ import unicode_literals
# from PyQt5.QtGui import *
from PyQt5.QtCore import *
from PyQt5.QtWidgets import *
import sys
import numpy as np
import matplotlib
matplotlib.use('Qt5Agg')
from matplotlib.figure import Figure
from matplotlib.backends.backend_qt5agg import FigureCanvasQTAgg as FigureCanvas
from matplotlib.backends.backend_qt5agg import NavigationToolbar2QT as NavigationToolbar
from scipy.ndimage import imread
from scipy.ndimage.morphology import binary_dilation
from scipy.optimize import curve_fit, leastsq

更新

控制台中打印的问题紧随其后

142859 INFO: Loading module hook "hook-zmq.py"...

所以这应该意味着错误来自zmq?

最佳答案

我在另一个论坛上找到了答案。我更改了 Python\Lib\site-packages\Pyinstaller\compat.py 文件中的行号 369:

out = out.decode(encoding)

out = out.decode(encoding, errors='ignore')

out = out.decode(encoding, "replace")

现在我可以毫无问题地编译我的脚本了。我仍然不知道为什么我的问题首先会发生,但至少现在可以编译了。

关于python - 使用pyinstaller时出错: UnicodeDecodeError: 'utf-8' codec can't decode byte 0xff,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47692960/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com