鱼C论坛

 找回密码
 立即注册
查看: 1089|回复: 0

[技术交流] 关于pyinstaller无法报错的解决方案之一

[复制链接]
发表于 2022-1-22 09:22:19 | 显示全部楼层 |阅读模式

马上注册,结交更多好友,享用更多功能^_^

您需要 登录 才可以下载或查看,没有账号?立即注册

x
准备文件只有两个,一个是gui2.py,一个是图标文件lc.ico
我在文件目录下,开始按住shift然后右键点击鼠标打开powershell,输入了 pyinstaller -F -i gui2.py lc.ico,但是报错了。报错信息如下:
PS D:\二手车评估> pyinstaller -F -i lcsh.py lc.ico
170 INFO: PyInstaller: 4.5.1
170 INFO: Python: 3.8.0
172 INFO: Platform: Windows-10-10.0.19041-SP0
172 INFO: wrote D:\二手车评估\lc.spec
174 INFO: UPX is not available.
176 INFO: Extending PYTHONPATH with paths
['D:\\二手车评估', 'D:\\二手车评估']
710 INFO: checking Analysis
710 INFO: Building Analysis because Analysis-00.toc is non existent
710 INFO: Initializing module dependency graph...
713 INFO: Caching module graph hooks...
735 INFO: Analyzing base_library.zip ...
4212 INFO: Caching module dependency graph...
4370 INFO: running Analysis Analysis-00.toc
4385 INFO: Adding Microsoft.Windows.Common-Controls to dependent assemblies of final executable
  required by d:\users\83643\appdata\local\programs\python\python38\python.exe
4429 INFO: Analyzing D:\二手车评估\lc.ico
Traceback (most recent call last):
  File "d:\users\83643\appdata\local\programs\python\python38\lib\runpy.py", line 192, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "d:\users\83643\appdata\local\programs\python\python38\lib\runpy.py", line 85, in _run_code
    exec(code, run_globals)
  File "D:\Users\83643\AppData\Local\Programs\Python\Python38\Scripts\pyinstaller.exe\__main__.py", line 7, in <module>
  File "d:\users\83643\appdata\local\programs\python\python38\lib\site-packages\PyInstaller\__main__.py", line 126, in run
    run_build(pyi_config, spec_file, **vars(args))
  File "d:\users\83643\appdata\local\programs\python\python38\lib\site-packages\PyInstaller\__main__.py", line 65, in run_build
    PyInstaller.building.build_main.main(pyi_config, spec_file, **kwargs)
  File "d:\users\83643\appdata\local\programs\python\python38\lib\site-packages\PyInstaller\building\build_main.py", line 815, in main
    build(specfile, kw.get('distpath'), kw.get('workpath'), kw.get('clean_build'))
  File "d:\users\83643\appdata\local\programs\python\python38\lib\site-packages\PyInstaller\building\build_main.py", line 762, in build
    exec(code, spec_namespace)
  File "D:\二手车评估\lc.spec", line 7, in <module>
    a = Analysis(['lc.ico'],
  File "d:\users\83643\appdata\local\programs\python\python38\lib\site-packages\PyInstaller\building\build_main.py", line 294, in __init__
    self.__postinit__()
  File "d:\users\83643\appdata\local\programs\python\python38\lib\site-packages\PyInstaller\building\datastruct.py", line 159, in __postinit__
    self.assemble()
  File "d:\users\83643\appdata\local\programs\python\python38\lib\site-packages\PyInstaller\building\build_main.py", line 467, in assemble
    priority_scripts.append(self.graph.add_script(script))
  File "d:\users\83643\appdata\local\programs\python\python38\lib\site-packages\PyInstaller\depend\analysis.py", line 304, in add_script
    self._top_script_node = super(PyiModuleGraph, self).add_script(
  File "d:\users\83643\appdata\local\programs\python\python38\lib\site-packages\PyInstaller\lib\modulegraph\modulegraph.py", line 1419, in add_script
    contents = fp.read() + '\n'
  File "d:\users\83643\appdata\local\programs\python\python38\lib\codecs.py", line 322, in decode
    (result, consumed) = self._buffer_decode(data, self.errors, final)
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xa8 in position 14: invalid start byte

我寻找解决方案,我试着改成英文目录:无济于事。

最后三个方案可行:
1. pyinstaller -F gui2.py  只生成exe文件,但是有黑框不好看
2.pyinstaller -F -w gui2.py, 这样没有黑框,我还是很满足的,但是没有图表
3.看 了https://zhuanlan.zhihu.com/p/121566859之后我发现是不是顺序反了,我试着写成  pyinstaller -F-w -i lc.ico gui2.py 结果成功了!!!!


谢天谢地啊!!
想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

小黑屋|手机版|Archiver|鱼C工作室 ( 粤ICP备18085999号-1 | 粤公网安备 44051102000585号)

GMT+8, 2025-1-12 10:03

Powered by Discuz! X3.4

© 2001-2023 Discuz! Team.

快速回复 返回顶部 返回列表