PyInstaller打包python程序
PyInstaller打包python程序:例:打包外参变换修正
问题1
打包时报错
from PyInstaller.__main__ import run
ModuleNotFoundError: No module named 'PyInstaller'
原因分析:
github isuss 上说pip的高版本导致的,成功的案例pip==19.0.3
解决方案:
降pip版本为19.0.3
问题2
打包后运行缺少dll
原因分析:
找不到dll
解决方案:
打包时加入dll路径
pyinstaller -D -p .\DLLs xxx\fine_tuning_extrinsic.py
问题3
无法使用不同环境中的pyinstaller 进行打包,即使加入了dll路径
问题4
Exception in thread Thread-1:
Traceback (most recent call last):
File "threading.py", line 932, in _bootstrap_inner
File "threading.py", line 870, in run
File "gooey\gui\processor.py", line 70, in _forward_stdout
File "gooey\gui\processor.py", line 84, in _extract_progress
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xc4 in position 0: invalid continuation byte
原因分析:
gooey编码问题
解决方案:
参考:https://cloud.tencent.com/developer/article/1981252
修改:
D:\xxx\Lib\site-packages\gooey\gui\processor.py
pub.send_message(events.PROGRESS_UPDATE, progress=_progress)
if _progress is None or self.hide_progress_msg is False:
try:
pub.send_message(events.CONSOLE_UPDATE,
msg=line.decode(self.encoding))
except UnicodeDecodeError :
pub.send_message(events.CONSOLE_UPDATE,
msg=line.decode("gbk"))
pub.send_message(events.EXECUTION_COMPLETE)
def _extract_progress(self, text):
'''
Finds progress information in the text using the
user-supplied regex and calculation instructions
'''
# monad-ish dispatch to avoid the if/else soup
try:
find = partial(re.search, string=text.strip().decode(self.encoding))
except UnicodeDecodeError :
find = partial(re.search, string=text.strip().decode("gbk"))
pyinstaller -D -p .\DLLs xxx\fine_tuning_extrinsic.py
bingo!