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

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

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

问题

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

import eel
from pathlib import Path
from asammdf import MDF
from pathlib import Path
import glob
import sys
import os
from datetime import timedelta

eel.init("路径\到\文件夹\Python")
def python_code():
    # 使用asammdf的Python脚本

@eel.expose

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

错误消息如下:

asammdf\mdf.py:4597: UserWarning: 方法`extract_bus_logging`中的参数`ignore_invalid_signals`不再使用将来将被移除
Traceback (most recent call last):
  File "eel\__init__.py", line 281, in _process_message
  File "converterrxd_csv.py", line 79, in python_code
  File "asammdf\mdf.py", line 4625, in extract_bus_logging
  File "asammdf\mdf.py", line 4666, in _extract_can_logging
  File "asammdf\blocks\utils.py", line 1807, in load_can_database
  File "canmatrix\formats\__init__.py", line 71, in loadp
  File "canmatrix\formats\__init__.py", line 86, in load
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.

import eel
from pathlib import Path
from asammdf import MDF
from pathlib import Path
import glob
import sys
import os
from datetime import timedelta


eel.init("path\to\folder\Python")
def python_code():
    # a python script that uses asammdf

@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 --

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
Traceback (most recent call last):
  File "eel\__init__.py", line 281, in _process_message
  File "converterrxd_csv.py", line 79, in pythoncode
  File "asammdf\mdf.py", line 4625, in extract_bus_logging
  File "asammdf\mdf.py", line 4666, in _extract_can_logging
  File "asammdf\blocks\utils.py", line 1807, in load_can_database
  File "canmatrix\formats\__init__.py", line 71, in loadp
  File "canmatrix\formats\__init__.py", line 86, in load
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:

确定