本文介绍了使用pyinstaller时没有名为kivymd.Effects的模块的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
嗨,请任何人帮忙我的exe文件在我尝试运行它时出现此错误,我已在main.spec文件中将kivymd添加到我的iddenImports=[";kivymd";]中,我还尝试使用pip安装kivymd,但仍出现错误。
Traceback (most recent call last):
File "kivylangparser.py", line 472, in execute_directives
ModuleNotFoundError: No module named 'kivymd.effects'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "kivylangparser.py", line 474, in execute_directives
ModuleNotFoundError: No module named 'kivymd.effects'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "main.py", line 28, in <module>
from kivymd.uix.datatables import MDDataTable
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 "PyInstallerloaderpyimod03_importers.py", line 546, in exec_module
File "kivymduixdatatables.py", line 307, in <module>
File "kivylanguilder.py", line 373, in load_string
File "kivylangparser.py", line 402, in __init__
File "kivylangparser.py", line 508, in parse
File "kivylangparser.py", line 485, in execute_directives
kivy.lang.parser.ParserException: Parser: File "<inline>", line 3:
...
1:
2:#:import DEVICE_TYPE kivymd.material_resources.DEVICE_TYPE
>> 3:#:import StiffScrollEffect kivymd.effects.stiffscroll.StiffScrollEffect
4:
5:
...
Unable to import package 'kivymd.effects.stiffscroll.StiffScrollEffect'
推荐答案
我在同一问题上挣扎了几天,所以下面是解决方法。
pyinstaller没有导入效果模块,因为它不在kivymd钩子列表(Kivymd_Hooks_Path)中,您需要手动添加:
1转到.AppDataLocalProgramsPythonPython38Libsite-packageskivymd(或您的kivymd路径),修改__init__.py
添加效果路径:
原件:
.
path = os.path.dirname(__file__)
"""Path to KivyMD package directory."""
fonts_path = os.path.join(path, f"fonts{os.sep}")
"""Path to fonts directory."""
images_path = os.path.join(path, f"images{os.sep}")
"""Path to images directory."""
.
修改:
....
path = os.path.dirname(__file__)
"""Path to KivyMD package directory."""
fonts_path = os.path.join(path, f"fonts{os.sep}")
"""Path to fonts directory."""
images_path = os.path.join(path, f"images{os.sep}")
"""Path to images directory."""
effects_path = os.path.join(path, f"effects{os.sep}")
"""Path to effects directory."""
...
2转到.kivymd oolspackagingpyinstaller并修改hook-kivymd.py
并添加效果路径:
datas = [
(
kivymd.fonts_path,
str(Path("kivymd").joinpath(Path(kivymd.fonts_path).name)),
),
(
kivymd.images_path,
str(Path("kivymd").joinpath(Path(kivymd.images_path).name)),
),
(
kivymd.effects_path,
str(Path("kivymd").joinpath(Path(kivymd.effects_path).name)),
),
]
完成后,创建一个新的可分发文件,即:d
这篇关于使用pyinstaller时没有名为kivymd.Effects的模块的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!