执行插图划线.exec文件时出现PyInstaller错误
问题描述
我正在尝试创建一个.exe文件来运行用Ploly 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')
相关文章