1 回答

TA貢獻(xiàn)1813條經(jīng)驗(yàn) 獲得超2個(gè)贊
那么你還在為此苦苦掙扎嗎?
您需要更新規(guī)范文件的“data”和“hiddenimports”部分,以確保庫(kù)被導(dǎo)入。我在下面向您展示了我的(效果很好)。您需要修改它以包含 openpyxl、tkinter 和 pandas。
a = Analysis(['main.py'],
pathex=['C:\\Users\\user\\PycharmProjects\\PlotlyExample'],
binaries=[],
datas=[('C:\\Users\\user\\PycharmProjects\\PlotlyExample\\venv\\Lib\\site-packages\\plotly\\', 'plotly'),
('C:\\Users\\user\\PycharmProjects\\PlotlyExample\\venv\\Lib\\site-packages\\kaleido\\', 'kaleido'),
('C:\\Users\\user\\PycharmProjects\\PlotlyExample\\venv\\Lib\\site-packages\\pptx\\', 'pptx'),],
hiddenimports=['pandas','numpy','plotly','pptx'],
hookspath=[],
runtime_hooks=[],
excludes=[],
win_no_prefer_redirects=False,
win_private_assemblies=False,
cipher=block_cipher,
noarchive=False)
實(shí)際上,我遇到了與您關(guān)于plotly.json 相同的錯(cuò)誤,所以我知道上述解決方案有效。:)
同樣重要的是,如果您要導(dǎo)出靜態(tài)圖像,請(qǐng)?jiān)谝?guī)范文件中包含 Kaleido 或 Orcas。我正在使用 Kaleido,因此您可以在我的規(guī)范文件設(shè)置中看到它。
然后通過以下方式運(yùn)行 PyInstaller: pyinstaller main.spec --clean
其中 main.spec 是您的規(guī)范文件(更改名稱)。
編輯:為了讓事情變得更容易,這是我的整個(gè)規(guī)范文件:
# -*- mode: python ; coding: utf-8 -*-
# Command to compile the spec and python files
# pyinstaller main.spec --clean --onefile
block_cipher = None
a = Analysis(['main.py'],
pathex=['C:\\Users\\user\\PycharmProjects\\PlotlyExample'],
binaries=[],
datas=[('C:\\Users\\user\\PycharmProjects\\PlotlyExample\\venv\\Lib\\site-packages\\plotly\\', 'plotly'),
('C:\\Users\\user\\PycharmProjects\\PlotlyExample\\venv\\Lib\\site-packages\\kaleido\\', 'kaleido'),
('C:\\Users\\user\\PycharmProjects\\PlotlyExample\\venv\\Lib\\site-packages\\pptx\\', 'pptx'),],
hiddenimports=['pandas','numpy','plotly','pptx'],
hookspath=[],
runtime_hooks=[],
excludes=[],
win_no_prefer_redirects=False,
win_private_assemblies=False,
cipher=block_cipher,
noarchive=False)
pyz = PYZ(a.pure, a.zipped_data,
cipher=block_cipher)
exe = EXE(pyz,
a.scripts,
[],
exclude_binaries=True,
name='main',
debug=False,
bootloader_ignore_signals=False,
strip=False,
upx=True,
console=True )
coll = COLLECT(exe,
a.binaries,
a.zipfiles,
a.datas,
strip=False,
upx=True,
upx_exclude=[],
name='main')
添加回答
舉報(bào)