Pyinstaller:.exe文件在IDE中的运行方式不同。

huangapple go评论88阅读模式
英文:

Pyinstaller : .exe file doesn't work the same way as in IDE

问题

我编写了一个使用eel作为GUI的Python脚本,用于在文件夹中进行文件的转换和一些计算。为此,我使用了一个名为asammdf的Python库。在集成开发环境(IDE)中,代码可以正常工作,但当我使用pyinstaller创建.exe文件时,代码似乎无法以相同的方式运行。

  1. import eel
  2. from pathlib import Path
  3. from asammdf import MDF
  4. from pathlib import Path
  5. import glob
  6. import sys
  7. import os
  8. from datetime import timedelta
  9. eel.init("路径\到\文件夹\Python")
  10. def python_code():
  11. # 使用asammdf的Python脚本
  12. @eel.expose

我尝试将asammdf目录复制到Python文件夹中,pyinstaller似乎将其包括在.exe分发文件夹中,但仍然无法正常工作。是否有人能帮助我解决这个问题?

错误消息如下:

  1. asammdf\mdf.py:4597: UserWarning: 方法`extract_bus_logging`中的参数`ignore_invalid_signals`不再使用将来将被移除
  2. Traceback (most recent call last):
  3. File "eel\__init__.py", line 281, in _process_message
  4. File "converterrxd_csv.py", line 79, in python_code
  5. File "asammdf\mdf.py", line 4625, in extract_bus_logging
  6. File "asammdf\mdf.py", line 4666, in _extract_can_logging
  7. File "asammdf\blocks\utils.py", line 1807, in load_can_database
  8. File "canmatrix\formats\__init__.py", line 71, in loadp
  9. File "canmatrix\formats\__init__.py", line 86, in load
  10. KeyError: 'canmatrix.formats.dbc'

我还尝试安装can-matrix包,但这并未解决问题。

英文:

I have written a python script, using eel for the GUI, that converts & does some calculations on files in a folder. For this, i am using a python library called asammdf. The code works well in an IDE but when i use pyinstallerand create a .exe file the code doesn't seem to work the same way.

  1. import eel
  2. from pathlib import Path
  3. from asammdf import MDF
  4. from pathlib import Path
  5. import glob
  6. import sys
  7. import os
  8. from datetime import timedelta
  9. eel.init("path\to\folder\Python")
  10. def python_code():
  11. # a python script that uses asammdf
  12. @eel.expose

I have tried copying the asammdf directory into the python folder and pyinstaller seems to include it in the .exe dist folder but still it doesn't work. Can anyone help me out please?

The error message comes as --

  1. asammdf\mdf.py:4597: UserWarning: The argument `ignore_invalid_signals` from the method `extract_bus_logging` is no longer used and will be removed in the future
  2. Traceback (most recent call last):
  3. File "eel\__init__.py", line 281, in _process_message
  4. File "converterrxd_csv.py", line 79, in pythoncode
  5. File "asammdf\mdf.py", line 4625, in extract_bus_logging
  6. File "asammdf\mdf.py", line 4666, in _extract_can_logging
  7. File "asammdf\blocks\utils.py", line 1807, in load_can_database
  8. File "canmatrix\formats\__init__.py", line 71, in loadp
  9. File "canmatrix\formats\__init__.py", line 86, in load
  10. KeyError: 'canmatrix.formats.dbc'

I tried installing the can-matrix package as well but that doesn't solve the problem.

答案1

得分: 1

你需要添加canmatrix的隐藏导入

请查看https://github.com/danielhrisca/asammdf/blob/180a1588737ae7aaf367aaa8fd1c81aff616df16/asammdf.spec#L37

英文:

You need to add the hidden import for canmatrix

see https://github.com/danielhrisca/asammdf/blob/180a1588737ae7aaf367aaa8fd1c81aff616df16/asammdf.spec#L37

huangapple
  • 本文由 发表于 2023年2月6日 22:01:57
  • 转载请务必保留本文链接:https://go.coder-hub.com/75362318.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定