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

问题描述 投票:0回答:1

我正在尝试创建一个.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文件夹。

python plotly pyinstaller plotly-dash
1个回答
0
投票

似乎我们需要修改.spec文件(请参见下面的sample.spec)。修改规范文件后,在控制台中输入“ pyinstaller ***。spec”,然后可以从浏览器连接破折号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')
© www.soinside.com 2019 - 2024. All rights reserved.