TShopping

 找回密碼
 註冊
搜索
查看: 368|回復: 0
打印 上一主題 下一主題

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

[複製鏈接]
跳轉到指定樓層
1#
發表於 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語句
  • 如圖



文章出處: NetYea 網頁設計

 

臉書網友討論
*滑块验证:
您需要登錄後才可以回帖 登錄 | 註冊 |

本版積分規則



Archiver|手機版|小黑屋|免責聲明|TShopping

GMT+8, 2024-4-30 01:59 , Processed in 0.053292 second(s), 25 queries .

本論壇言論純屬發表者個人意見,與 TShopping綜合論壇 立場無關 如有意見侵犯了您的權益 請寫信聯絡我們。

Powered by Discuz! X3.2

© 2001-2013 Comsenz Inc.

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