首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >如何将带有pyinstaller的Plotly-Dash应用程序打包成windows的单个exe文件?

如何将带有pyinstaller的Plotly-Dash应用程序打包成windows的单个exe文件?
EN

Stack Overflow用户
提问于 2020-02-04 10:14:34
回答 1查看 719关注 0票数 1

我有一个运行情节仪表板的脚本。当我把它打包成

代码语言:javascript
运行
复制
pyinstaller --onefile script.py

并运行生成的.exe文件,我得到了错误消息:

代码语言:javascript
运行
复制
FileNotFoundError: [Errno 2] No such file or directory: 'C:\\Users\\my_user\\AppData\\Local\\Temp\\_MEI161122\\dash_html_components\\package-info.json'
[5968] Failed to execute script

这里到底发生了什么,我该如何修复它?

EN

回答 1

Stack Overflow用户

发布于 2021-01-09 03:28:25

我认为解决方案是将该组件添加到specfile的datas列表中。

代码语言:javascript
运行
复制
...
datas=[('C:\\Users\\username\\anaconda3\\envs\\ms-mint\\lib\\site-packages\\dash_html_components', '.\\dash_html_components'), ...] 
...

虽然我不确定。我停止使用--onefile选项,因为启动应用程序的时间太长了。相反,我继续使用--onedir

完整的规范文件:

代码语言:javascript
运行
复制
# -*- mode: python ; coding: utf-8 -*-

block_cipher = None


a = Analysis(['..\\scripts\\Mint.py'],
             pathex=['C:\\Users\\username\\workspace\\ms-mint'],
             binaries=[],
             datas=[('C:\\Users\\username\\anaconda3\\envs\\ms-mint\\lib\\site-packages\\dash_html_components', '.\\dash_html_components'),
                    ('C:\\Users\\username\\anaconda3\\envs\\ms-mint\\lib\\site-packages\\dash_table', '.\\dash_table'),
                    ('C:\\Users\\username\\anaconda3\\envs\\ms-mint\\lib\\site-packages\\dash_core_components', '.\\dash_core_components'),
                    ('C:\\Users\\username\\anaconda3\\envs\\ms-mint\\lib\\site-packages\\dash_renderer', '.\\dash_renderer'),
                    ('C:\\Users\\username\\anaconda3\\envs\\ms-mint\\lib\\site-packages\\dash_bootstrap_components', '.\\dash_bootstrap_components'),
                    ('C:\\Users\\username\\anaconda3\\envs\\ms-mint\\lib\\site-packages\\dash_html_components', '.\\dash_html_components'),
                    ('C:\\Users\\username\\anaconda3\\envs\\ms-mint\\lib\\site-packages\\dash_extensions', '.\\dash_extensions'),
                    ('C:\\Users\\username\\anaconda3\\envs\\ms-mint\\lib\\site-packages\\plotly', '.\\plotly'),
                    ('C:\\Users\\username\\anaconda3\\envs\\ms-mint\\lib\\site-packages\\pyopenms\\share', '.\\pyopenms\\share'),
                    ('C:\\Users\\username\\anaconda3\\envs\\ms-mint\\lib\\site-packages\\pymzml', '.\\pymzml'),

                    ],
             hiddenimports=['pkg_resources.py2_warn'],  
             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='Mint',
          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='Mint')
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/60049673

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档