找回密碼
 註冊
搜索
查看: 968|回復: 0

[教學] Python用PyInstaller打包成exe時報錯:tuple index out of range

[複製鏈接]
發表於 2023-10-31 22:04:26 | 顯示全部樓層 |閱讀模式
 
Push to Facebook
  1. File "C:\Users\xx\AppData\Local\Programs\Python\Python310\lib\site-packages\PyInstaller\lib\modulegraph\modulegraph.py", line 2645, in _scan_code
  2.     self._scan_bytecode(
  3.   File "C:\Users\xx\AppData\Local\Programs\Python\Python310\lib\site-packages\PyInstaller\lib\modulegraph\modulegraph.py", line 2749, in _scan_bytecode
  4.     for inst in util.iterate_instructions(module_code_object):
  5.   File "C:\Users\xx\AppData\Local\Programs\Python\Python310\lib\site-packages\PyInstaller\lib\modulegraph\util.py", line 147, in iterate_instructions
  6.     yield from iterate_instructions(constant)
  7.   File "C:\Users\xx\AppData\Local\Programs\Python\Python310\lib\site-packages\PyInstaller\lib\modulegraph\util.py", line 139, in iterate_instructions
  8.     yield from get_instructions(code_object)
  9.   File "C:\Users\xx\AppData\Local\Programs\Python\Python310\lib\dis.py", line 338, in _get_instructions_bytes
  10.     argval, argrepr = _get_const_info(arg, constants)
  11.   File "C:\Users\xx\AppData\Local\Programs\Python\Python310\lib\dis.py", line 292, in _get_const_info
  12.     argval = const_list[const_index]
複製代碼

運行環境

  1. win10
  2. python3.10
  3. pycharm2021
複製代碼


解決方案:
  • 定位到C:\Users\hp\AppData\Local\Programs\Python\Python310\Lib\dis.py(每個人的路徑可能不同)
  • 找到_unpack_opargs(code)函數
  • 在else中加入extended_arg = 0語句
  • 如圖

Python PyInstaller 打包 exe tuple

Python PyInstaller 打包 exe tuple


文章出處: NetYea 網頁設計
 
您需要登錄後才可以回帖 登錄 | 註冊

本版積分規則

Archiver|手機版|小黑屋|TShopping

GMT+8, 2025-5-1 04:23 , Processed in 0.024116 second(s), 24 queries .

Powered by Discuz! X3.5

© 2001-2025 Discuz! Team.

快速回復 返回頂部 返回列表