gpt4 book ai didi

python - pyinstaller 因 plotly 而失败

转载 作者:行者123 更新时间:2023-11-28 21:03:50 29 4
gpt4 key购买 nike

我正在使用 pyinstaller 编译我当前的程序,它似乎无法以 plotly 的方式处理所有必需的文件。它自己运行良好,没有 plotly 它也可以编译和运行。

似乎是因为找不到文件“default-schema.json”,我什至无法在我的驱动器上的任何地方找到它。


Traceback (most recent call last): File "comdty_runtime.py", line 17, in File "", line 2237, in _find_and_load File "", line 2226, in _find_and_load_unlocked File "", line 1191, in _load_unlocked File "", line 1161, in _load_backward_compatible File "d:\users\ktehrani\appdata\local\continuum\anaconda3\envs\py34\lib\site-p ackages\PyInstaller\loader\pyimod03_importers.py", line 389, in load_module exec(bytecode, module.dict) File "actual_vs_mai.py", line 12, in File "", line 2237, in _find_and_load File "", line 2226, in _find_and_load_unlocked File "", line 1191, in _load_unlocked File "", line 1161, in _load_backward_compatible File "d:\users\ktehrani\appdata\local\continuum\anaconda3\envs\py34\lib\site-p ackages\PyInstaller\loader\pyimod03_importers.py", line 389, in load_module exec(bytecode, module.dict) File "site-packages\plotly__init__.py", line 31, in File "", line 2237, in _find_and_load File "", line 2226, in _find_and_load_unlocked File "", line 1191, in _load_unlocked
File "", line 1161, in _load_backward_compatible File "d:\users*\appdata\local\continuum\anaconda3\envs\py34\lib\site-p ackages\PyInstaller\loader\pyimod03_importers.py", line 389, in load_module exec(bytecode, module.dict) File "site-packages\plotly\graph_objs__init__.py", line 14, in
File "", line 2237, in _find_and_load
File "", line 2226, in _find_and_load_unlocked File "", line 1191, in _load_unlocked File "", line 1161, in _load_backward_compatible File "d:\users*\appdata\local\continuum\anaconda3\envs\py34\lib\site-p ackages\PyInstaller\loader\pyimod03_importers.py", line 389, in load_module exec(bytecode, module.dict) File "site-packages\plotly\graph_objs\graph_objs.py", line 34, in File "", line 2237, in _find_and_load
File "", line 2226, in _find_and_load_unlocked File "", line 1191, in _load_unlocked File "", line 1161, in _load_backward_compatible File "d:\users*\appdata\local\continuum\anaconda3\envs\py34\lib\site-p ackages\PyInstaller\loader\pyimod03_importers.py", line 389, in load_module exec(bytecode, module.dict) File "site-packages\plotly\graph_reference.py", line 578, in
File "site-packages\plotly\graph_reference.py", line 70, in get_graph_referenc e File "site-packages\setuptools-27.2.0-py3.4.egg\pkg_resources__init__.py", li ne 1215, in resource_string File "site-packages\setuptools-27.2.0-py3.4.egg\pkg_resources__init__.py", li ne 1457, in get_resource_string File "site-packages\setuptools-27.2.0-py3.4.egg\pkg_resources__init__.py", li ne 1530, in _get File "d:\users*\appdata\local\continuum\anaconda3\envs\py34\lib\site-p ackages\PyInstaller\loader\pyimod03_importers.py", line 474, in get_data with open(path, 'rb') as fp: FileNotFoundError: [Errno 2] No such file or directory: 'H:\Python\Commodity_M AI_Trade_List\Code\dist\comdty_runtime\plotly\package_data\default-schema. json' Failed to execute script comdty_runtime

最佳答案

我遇到了同样的问题,并通过 pyinstaller 文档找出解决方法:

pyinstaller 会创建一个与您的 .py 文件同名的 .spec 文件。在a = Analysis下,你会发现datas = []

a = Analysis(['graphic_interface.py'],
pathex=[xxx],
binaries=[],
datas=[],
hiddenimports=[],
hookspath=[],
runtime_hooks=[],
excludes=[],
win_no_prefer_redirects=False,
win_private_assemblies=False,
cipher=block_cipher,
noarchive=False)

在那里你添加了 plotly 的路径。相对路径对我不起作用,所以我设置了绝对路径

datas=[('C:\\Users\\Me\\PycharmProjects\\Project\\venv\\Lib\\site-packages\\plotly\\', 'plotly')],

现在运行 pyinstaller 时必须使用 spec 文件

pyinstaller myproject.spec myproject.py

您不必担心其他命令,例如 oneFile 等,因为它们已经保存在 .spec 文件中

关于python - pyinstaller 因 plotly 而失败,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46099695/

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