ModuleNotFoundError:没有名为“kivymd.stiffscroll”的模块

问题描述 投票:0回答:2

可能的解决方案: 有人认为发生这个问题是因为我安装的 kivymd 仅在终端上,而不是在我的 IDE (Pycharm) 的 Python 解释器上。我对此不太确定,因为首先,我在终端上 pip install kivymd 并手动将 kivy 包添加到我的 IDE 的 Python 解释器中。其次,我的 IDE Python 解释器位于“/Desktop/CoinSnack4/venv/bin/python”,而我的 kivymd 安装在终端上的“/Users/kienletrung/Desktop/CoinSnack4/venv”(我通过输入“将 $VIRTUAL_ENV" 回显到终端)。

此外,我的程序在使用 IDE 运行时运行良好。只有当我打开它的.exe 文件时才会出现以下错误...

嗨,请任何人都可以帮忙解决这个问题,我的 exe 文件抛出了这个错误:

此 Stackoverflow 中的答案(使用 pyinstaller 时没有名为 kivymd.effects 的模块)对我不起作用...

[INFO   ] [Logger      ] Record log in /Users/kienletrung/.kivy/logs/kivy_22-01-18_0.txt
[INFO   ] [Kivy        ] v2.0.0
[INFO   ] [Kivy        ] Installed at "/var/folders/g4/1xyrvs4j721f0tlsddrbxch00000gn/T/_MEI2YvYUa/kivy/__init__.pyc"
[INFO   ] [Python      ] v3.8.1 (v3.8.1:1b293b6006, Dec 18 2019, 14:08:53) 
[Clang 6.0 (clang-600.0.57)]
[INFO   ] [Python      ] Interpreter at "/Users/kienletrung/Desktop/CoinSnack4/dist/financiaz"
[INFO   ] [Factory     ] 186 symbols loaded
[INFO   ] [Image       ] Providers: img_tex, img_imageio, img_dds, img_sdl2, img_pil (img_ffpyplayer ignored)
[INFO   ] [KivyMD      ] 0.104.2.dev0 (installed at "/var/folders/g4/1xyrvs4j721f0tlsddrbxch00000gn/T/_MEI2YvYUa/kivymd/__init__.pyc")
[INFO   ] [Text        ] Provider: sdl2
[INFO   ] [Window      ] Provider: sdl2
[INFO   ] [GL          ] Using the "OpenGL ES 2" graphics system
[INFO   ] [GL          ] Backend used <sdl2>
[INFO   ] [GL          ] OpenGL version <b'2.1 INTEL-14.7.18'>
[INFO   ] [GL          ] OpenGL vendor <b'Intel Inc.'>
[INFO   ] [GL          ] OpenGL renderer <b'Intel(R) HD Graphics 6000'>
[INFO   ] [GL          ] OpenGL parsed version: 2, 1
[INFO   ] [GL          ] Shading version <b'1.20'>
[INFO   ] [GL          ] Texture max size <16384>
[INFO   ] [GL          ] Texture max units <16>
[INFO   ] [Window      ] auto add sdl2 input provider
[INFO   ] [Window      ] virtual keyboard not allowed, single mode, not docked
[ERROR  ] 
Traceback (most recent call last):
  File "kivy/lang/parser.py", line 472, in execute_directives
ModuleNotFoundError: No module named 'kivymd.stiffscroll'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "kivy/lang/parser.py", line 474, in execute_directives
ModuleNotFoundError: No module named 'kivymd.stiffscroll'
 Traceback (most recent call last):
   File "kivy/lang/parser.py", line 472, in execute_directives
 ModuleNotFoundError: No module named 'kivymd.stiffscroll'
 
 During handling of the above exception, another exception occurred:
 
 Traceback (most recent call last):
   File "kivy/lang/parser.py", line 474, in execute_directives
 ModuleNotFoundError: No module named 'kivymd.stiffscroll'
 
 During handling of the above exception, another exception occurred:
 
 Traceback (most recent call last):
   File "main.py", line 24, in <module>
   File "<frozen importlib._bootstrap>", line 991, in _find_and_load
   File "<frozen importlib._bootstrap>", line 975, in _find_and_load_unlocked
   File "<frozen importlib._bootstrap>", line 671, in _load_unlocked
   File "PyInstaller/loader/pyimod03_importers.py", line 540, in exec_module
   File "kivymd/uix/datatables.py", line 54, in <module>
   File "kivy/lang/builder.py", line 373, in load_string
   File "kivy/lang/parser.py", line 402, in __init__
   File "kivy/lang/parser.py", line 508, in parse
   File "kivy/lang/parser.py", line 483, 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.stiffscroll.StiffScrollEffect
       4:
       5:
 ...
 Unable to import package 'kivymd.stiffscroll.StiffScrollEffect'
[8390] Failed to execute script main
logout
Saving session...
...copying shared history...
...saving history...truncating history files...
...completed.

[Process completed]


看来错误的发生都是因为kivymd/uix/database.py中的database.py文件由于某种原因无法使代码“#:import StiffScrollEffect kivymd.stiffscroll.StiffScrollEffect”起作用! Picture of database.py

如果有帮助,这是我的规格文件:

# -*- mode: python ; coding: utf-8 -*-

from kivymd import hooks_path as kivymd_hooks_path
block_cipher = None


#changes the '/Users/kienletrung/Desktop/CoinSnack_MiniIA/main.py' below to the
#path to the python python file of the whole project. change the #'/Users/kienletrung/Desktop/CoinSnack_MiniIA' below to the folder that holds the previous python file.
a = Analysis(['/Users/kienletrung/Desktop/FinanciazIA/main.py'],
             pathex=['/Users/kienletrung/Desktop/FinanciazIA'],
             binaries=[],
             datas=[],
             hiddenimports=["kivymd"],
             hookspath=[kivymd_hooks_path],
             runtime_hooks=[],
             excludes=['_tkinter', 'Tkinter', 'enchant', 'twisted'],
             win_no_prefer_redirects=False,
             win_private_assemblies=False,
             cipher=block_cipher,
             noarchive=False)
pyz = PYZ(a.pure, a.zipped_data,
             cipher=block_cipher)

#adds other files that are not the main python file with the way below: (needs to change the #'/Users/kienletrung/Desktop/CoinSnack_MiniIA/main.kv' to the appropriate path to the file)
a.datas += [('main.kv', '/Users/kienletrung/Desktop/FinanciazIA/main.kv', 'DATA'), ('Financiaz.png', '/Users/kienletrung/Desktop/FinanciazIA/Financiaz.png', 'DATA')]

#needs to change '/Users/kienletrung/Desktop/CoinSnack_MiniIA' to the path that holds the data that I add in the above line. change the "coinsnack" name to appropriate app name.
exe = EXE(pyz, Tree('/Users/kienletrung/Desktop/FinanciazIA', 'Data'),
          a.scripts,
          a.binaries,
          a.zipfiles,
          a.datas,
          [],
          name='financiaz',
          debug=False,
          bootloader_ignore_signals=False,
          strip=False,
          upx=True,
          upx_exclude=[],
          runtime_tmpdir=None,
          console=False )
app = BUNDLE(exe,
             name='financiaz.app',
             icon=None,
             bundle_identifier=None)



我尝试了很多天,但仍然无法解决这个问题...如果您能帮助我,我将永远感激不已。 非常感谢!

pyinstaller kivymd
2个回答
1
投票
pip uninstall kivymd
pip install https://github.com/kivymd/KivyMD/archive/master.zip

0
投票

安装kivy-uix 安装 kivymd-utils 和我一起解决了

© www.soinside.com 2019 - 2024. All rights reserved.