gpt4 book ai didi

python - 执行 Plotly Dash .exec 文件时出现 PyInstaller 错误

转载 作者:行者123 更新时间:2023-12-04 00:01:58 25 4
gpt4 key购买 nike

我正在尝试创建一个 .exe 文件来运行使用 Plotly Dash 创建的 python 仪表板。一旦我使用 PyInstaller 创建文件并尝试运行它,我就会收到以下错误:

Traceback (most recent call last):
File "app.py", line 2, in <module>
File "<frozen importlib._bootstrap>", line 983, in _find_and_load
File "<frozen importlib._bootstrap>", line 967, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 677, in _load_unlocked
File "/Users/mohamedmartino/opt/anaconda3/lib/python3.7/site-packages/PyInstaller/loader/pyimod03_importers.py", line 623, in exec_module
exec(bytecode, module.__dict__)
File "site-packages/dash_core_components/__init__.py", line 12, in <module>
FileNotFoundError: [Errno 2] No such file or directory: '/var/folders/np/m30g9mj57h72n68qxc2tq61m0000gn/T/_MEI2yKNs4/dash_core_components/package-info.json'
[85571] Failed to execute script app
  • 我是编码新手,我不知道为什么找不到 dcc
    依赖。有没有更好的方法将我的模块编译成一个
    可执行文件?

  • 我有一些 python 模块和 excel 文件以及一个包含图像和 css 文件的 -asset 文件夹。

    最佳答案

    看来我们需要修改 .spec 文件(参见下面的 sample.spec)。
    修改规范文件后,在控制台输入'pyinstaller ***.spec'(似乎'--onefile'选项不起作用),然后你可以从浏览器连接你的破折号URL。

    #Sample.spec
    # -*- mode: python ; coding: utf-8 -*-

    #manually add Start to avoid rerusion limit error==>
    import sys
    sys.setrecursionlimit(5000)
    #manually add End<==

    block_cipher = None


    a = Analysis(['dashtest.py'],
    pathex=['C:\\Users\\Owner\\Documents\\python\\Simulatortest\\sandbox'],
    binaries=[],
    #modified Start==>
    datas=[
    ('C:\\Users\\Owner\\anaconda3\\pkgs\\dash-core-components-1.3.1-py_0\\site-packages\\dash_core_components\\', 'dash_core_components'),
    ('C:\\Users\\Owner\\anaconda3\\pkgs\\dash-html-components-1.0.1-py_0\\site-packages\\dash_html_components\\', 'dash_html_components'),
    ('C:\\Users\\Owner\\anaconda3\\pkgs\\dash-renderer-1.1.2-py_0\\site-packages\\dash_renderer\\','dash_renderer'),
    ],
    hiddenimports=['pkg_resources.py2_warn'],
    #modified End<==
    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='dashtest',
    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='dashtest')

    关于python - 执行 Plotly Dash .exec 文件时出现 PyInstaller 错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59914106/

    25 4 0
    Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
    广告合作:1813099741@qq.com 6ren.com