ModuleNotFoundError:没有名为“kivy.garden.matplotlib.backend_kivyagg”的模块

pobjuy32  于 2023-11-22  发布在  其他
关注(0)|答案(1)|浏览(155)

几天来,当我试图将使用matplotlib的kivy python应用程序转换为可执行文件(.exe)时,我遇到了一个问题。每次我都会得到这个错误"ModuleNotFoundError: No module named 'kivy.garden.matplotlib.backend_kivyagg'"。然而,在dist文件夹( "C:\Users\Patrick-Lévy N'da\oneDrive\Bureau\dev\dist\main\kivy\garden\matplotlib" )中,我有backend_kivyagg.pyc文件。当我运行我的程序时,它可以完美地工作,没有错误。一旦我删除使用matplotlib的部分,转换就可以完美地工作。
下面是我的main.spec文件:

from kivy_deps import sdl2, glew
# -*- mode: python ; coding: utf-8 -*-

block_cipher = None

a = Analysis(
    ['main.py'],
    pathex=[],
    binaries=[],
    datas=[],
    hiddenimports=['kivy.garden.matplotlib.backend_kivyagg'],
    hookspath=[],
    hooksconfig={},
    runtime_hooks=[],
    excludes=[],
    win_no_prefer_redirects=False,
    win_private_assemblies=False,
    cipher=block_cipher,
    noarchive=True,
)

a.datas += [("assets/trajets_type/trajets1.csv", "C:\\Users\\Patrick-Lévy N'da\\OneDrive\\Bureau\\dev\\assets\\trajets_type\\trajets1.csv", "DATA")]
a.datas += [("assets/trajets_type/trajets2.csv", "C:\\Users\\Patrick-Lévy N'da\\OneDrive\\Bureau\\dev\\assets\\trajets_type\\trajets2.csv", "DATA")]
a.datas += [("assets/img/icon.png", "C:\\Users\\Patrick-Lévy N'da\\OneDrive\\Bureau\\dev\\assets\\img\\icon.png", "DATA")]
a.datas += [("assets/img/logo.png", "C:\\Users\\Patrick-Lévy N'da\\OneDrive\\Bureau\\dev\\assets\\img\\logo.png", "DATA")]
a.datas += [("assets/fonts/Poppins-Regular.ttf", "C:\\Users\\Patrick-Lévy N'da\\OneDrive\\Bureau\\dev\\assets\\fonts\\Poppins-Regular.ttf", "DATA")]
a.datas += [("assets/guide.txt", "C:\\Users\\Patrick-Lévy N'da\\OneDrive\\Bureau\\dev\\assets\\guide.txt", "DATA")]

a.datas += [("assets/screens_designs/matty.kv", "C:\\Users\\Patrick-Lévy N'da\\OneDrive\\Bureau\\dev\\assets\\screens_designs\\matty.kv", "DATA")]
a.datas += [("assets/screens_designs/home_page.kv", "C:\\Users\\Patrick-Lévy N'da\\OneDrive\\Bureau\\dev\\assets\\screens_designs\\home_page.kv", "DATA")]

pyz = PYZ(a.pure, a.zipped_data, cipher=block_cipher)

exe = EXE(
    pyz,
    a.scripts,
    [('v', None, 'OPTION')],
    exclude_binaries=True,
    name='main',
    debug=True,
    bootloader_ignore_signals=False,
    strip=False,
    upx=True,
    console=False,
    disable_windowed_traceback=False,
    argv_emulation=False,
    target_arch=None,
    codesign_identity=None,
    entitlements_file=None,
    icon=['assets\\img\\icon.ico'],
)
coll = COLLECT(
    exe, Tree('C:\\Users\\Patrick-Lévy N\'da\\OneDrive\\Bureau\\dev\\assets\\'),
    a.binaries,
    a.zipfiles,
    a.datas,
    *[Tree(p) for p in (sdl2.dep_bins + glew.dep_bins)],
    strip=False,
    upx=True,
    upx_exclude=[],
    name='main',
)

字符串
和我使用

Kivy==2.2.1
Kivy-Garden==0.1.5
kivy-garden.graph==0.4.0
kivy-garden.matplotlib==0.1.1.dev0
kivy-matplotlib-widget==0.6.1
matplotlib==3.7.2
pyinstaller==5.6.2


我做了很多研究,也在youtube上看了很多视频,但我仍然没有找到解决方案。无论我用我的pyinstaller命令行是否使用--hidden-import,我都得到了相同的结果。谢谢你的帮助。

q3qa4bjr

q3qa4bjr1#

您从哪个目录运行安装程序,或者更确切地说,main.spec和您的应用程序文件的路径是如何关联的?
我的猜测是,导入没有查看相应的目录,因此没有找到matplotlib文件。也许this question关于导入 *.pyc文件包括一些提示?

相关问题