亚洲乱码中文字幕综合,中国熟女仑乱hd,亚洲精品乱拍国产一区二区三区,一本大道卡一卡二卡三乱码全集资源,又粗又黄又硬又爽的免费视频

pyinstaller打包可執(zhí)行文件出現(xiàn)KeyError的問(wèn)題

 更新時(shí)間:2023年11月07日 10:02:02   作者:sven365  
這篇文章主要介紹了pyinstaller打包可執(zhí)行文件出現(xiàn)KeyError的問(wèn)題,具有很好的參考價(jià)值,希望對(duì)大家有所幫助,如有錯(cuò)誤或未考慮完全的地方,望不吝賜教

pyinstaller打包可執(zhí)行文件出現(xiàn)KeyError

提示錯(cuò)誤信息

直接運(yùn)行python文件無(wú)問(wèn)題,使用pyinstaller打包生成可執(zhí)行文件,

運(yùn)行可執(zhí)行文件會(huì)出現(xiàn)以下報(bào)錯(cuò):

Traceback (most recent call last):
  File "excel2dbc.py", line 232, in <module>
  File "excel2dbc.py", line 226, in main
  File "canmatrix\formats\__init__.py", line 102, in dump
KeyError: 'canmatrix.formats.dbc'
[6340] Failed to execute script 'excel2dbc' due to unhandled exception!

原因分析

打包后的可執(zhí)行文件系統(tǒng)模塊字典 sys.modules 找不到對(duì)應(yīng)的鍵值canmatrix.formats.dbc 。

原因是在插入依賴包的時(shí)候import canmatrix只插入了基礎(chǔ)的模塊。

解決方法

增加相關(guān)子模塊的插入import canmatrix.formats.dbc,然后重新打包,生成的可執(zhí)行文件運(yùn)行正常。

Pyinstaller打包可執(zhí)行文件運(yùn)行在linux容器中

安裝說(shuō)明

在linux安裝pyinstaller

執(zhí)行打包命令

$python_path/bin/pyinstaller -F test.py

調(diào)用dist目錄下文件

./test

常見(jiàn)問(wèn)題

Python library not found: libpython3.9m.so.1.0, libpython3.9m.so, libpython3.9.so.1.0, libpython3.9.so, libpython3.9mu.so.1.0

重新編譯安裝python即可

./configure –prefix=/usr/local/python3.9 –enable-shared –with-ssl make make install

總結(jié)

以上為個(gè)人經(jīng)驗(yàn),希望能給大家一個(gè)參考,也希望大家多多支持腳本之家。

相關(guān)文章

最新評(píng)論