pyinstaller 因情节失败而失败 [英] pyinstaller fails with plotly

查看:38
本文介绍了pyinstaller 因情节失败而失败的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I am compiling my current program using pyinstaller and it seems to not be able to handle all required files in plotly. It runs fine on its own, and without plotly it can compile and run as well.

似乎无法找到我什至无法在驱动器上的任何位置找到的文件default-schema.json".

It seems be to failing to find a file "default-schema.json" that I cannot even locate anywhere on my drive.

Traceback(最近一次调用最后一次):文件comdty_runtime.py",行17,在文件"中,第 2237 行,在_find_and_load 文件",第 2226 行,在 _find_and_load_unlocked 文件"中,第 1191 行,在 _load_unlocked 文件"中,行1161,在 _load_backward_compatible 文件中"d:usersktehraniappdatalocalcontinuumanaconda3envspy34libsite-packagesPyInstallerloaderpyimod03_importers.py",第 389 行,在加载模块exec(bytecode, module.dict) 文件actual_vs_mai.py",第 12 行,在文件",第 2237 行,在_find_and_load 文件",第 2226 行,在 _find_and_load_unlocked 文件"中,第 1191 行,在 _load_unlocked 文件"中,行1161,在 _load_backward_compatible 文件中"d:usersktehraniappdatalocalcontinuumanaconda3envspy34libsite-packagesPyInstallerloaderpyimod03_importers.py",第 389 行,在加载模块exec(bytecode, module.dict) File "site-packagesplotly__init__.py",第 31 行,在 File"",第 2237 行,在 _find_and_load 文件中"",第 2226 行,在 _find_and_load_unlocked文件",第 1191 行,在 _load_unlocked
文件",第 1161 行,在_load_backward_compatible 文件d:users*appdatalocalcontinuumanaconda3envspy34libsite-packagesPyInstallerloaderpyimod03_importers.py",第 389 行,在加载模块exec(bytecode, module.dict) 文件site-packagesplotlygraph_objs__init__.py",第 14 行,在
文件",第 2237 行,在 _find_and_load
文件",第 2226 行,在_find_and_load_unlocked 文件",第 1191 行,在 _load_unlocked 文件",行1161,在 _load_backward_compatible 文件中"d:users*appdatalocalcontinuumanaconda3envspy34libsite-packagesPyInstallerloaderpyimod03_importers.py",第 389 行,在加载模块exec(bytecode, module.dict) 文件site-packagesplotlygraph_objsgraph_objs.py",第 34 行,在文件",第 2237 行,在 _find_and_load
文件",第 2226 行,在_find_and_load_unlocked 文件",第 1191 行,在 _load_unlocked 文件",行1161,在 _load_backward_compatible 文件中"d:users*appdatalocalcontinuumanaconda3envspy34libsite-packagesPyInstallerloaderpyimod03_importers.py",第 389 行,在加载模块exec(bytecode, module.dict) 文件site-packagesplotlygraph_reference.py",第 578 行,在
文件site-packagesplotlygraph_reference.py",第 70 行,在get_graph_reference 文件站点包setuptools-27.2.0-py3.4.eggpkg_resources__init__.py",第 1215 行,在 resource_string 文件中站点包setuptools-27.2.0-py3.4.eggpkg_resources__init__.py",第 1457 行,在 get_resource_string 文件中站点包setuptools-27.2.0-py3.4.eggpkg_resources__init__.py",第 1530 行,在 _get 文件中"d:users*appdatalocalcontinuumanaconda3envspy34libsite-packagesPyInstallerloaderpyimod03_importers.py",第 474 行,在获取数据使用 open(path, 'rb') as fp: FileNotFoundError: [Errno 2] No such file or directory: 'H:PythonCommodity_MAI_Trade_ListCodedistcomdty_runtimeplotlypackage_datadefault-schema.json' comdty_runtime 执行脚本失败

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:usersktehraniappdatalocalcontinuumanaconda3envspy34libsite-p ackagesPyInstallerloaderpyimod03_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:usersktehraniappdatalocalcontinuumanaconda3envspy34libsite-p ackagesPyInstallerloaderpyimod03_importers.py", line 389, in load_module exec(bytecode, module.dict) File "site-packagesplotly__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*appdatalocalcontinuumanaconda3envspy34libsite-p ackagesPyInstallerloaderpyimod03_importers.py", line 389, in load_module exec(bytecode, module.dict) File "site-packagesplotlygraph_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*appdatalocalcontinuumanaconda3envspy34libsite-p ackagesPyInstallerloaderpyimod03_importers.py", line 389, in load_module exec(bytecode, module.dict) File "site-packagesplotlygraph_objsgraph_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*appdatalocalcontinuumanaconda3envspy34libsite-p ackagesPyInstallerloaderpyimod03_importers.py", line 389, in load_module exec(bytecode, module.dict) File "site-packagesplotlygraph_reference.py", line 578, in
File "site-packagesplotlygraph_reference.py", line 70, in get_graph_referenc e File "site-packagessetuptools-27.2.0-py3.4.eggpkg_resources__init__.py", li ne 1215, in resource_string File "site-packagessetuptools-27.2.0-py3.4.eggpkg_resources__init__.py", li ne 1457, in get_resource_string File "site-packagessetuptools-27.2.0-py3.4.eggpkg_resources__init__.py", li ne 1530, in _get File "d:users*appdatalocalcontinuumanaconda3envspy34libsite-p ackagesPyInstallerloaderpyimod03_importers.py", line 474, in get_data with open(path, 'rb') as fp: FileNotFoundError: [Errno 2] No such file or directory: 'H:PythonCommodity_M AI_Trade_ListCodedistcomdty_runtimeplotlypackage_datadefault-schema. json' Failed to execute script comdty_runtime

推荐答案

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

I came across the same problem, and worked my way through the pyinstaller documentation to find out what to do:

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

pyinstaller creates a .spec file with the same name as your .py file. under a = Analysis, you will find 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 的路径.相对路径对我不起作用,所以我设置了一个绝对路径

there you add the path for plotly. a relative path didn't work for me, so I set an absolute path

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

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

now you have to use the spec file when running pyinstaller

pyinstaller myproject.spec myproject.py

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

you dont need to worry about other commands like oneFile etc, because they are already saved in the .spec file

这篇关于pyinstaller 因情节失败而失败的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆