ImportError: cannot import name 'modname_tkinter' from 'PyInstaller.compat'

ImportError: cannot import name 'modname_tkinter' from 'PyInstaller.compat'

PyInstaller:5.0.1 Python:3.7.9 输出:https://gist.github.com/phonebotco/eee157bd12a3b9f0792b2fcab9478636

我正在尝试使用此命令编译我的代码:

pyinstaller --onefile -F --uac-admin --icon="favicon_phonebot.ico" --exclude-module modname_tkinter --debug=all PhoneBot.py

我收到此错误消息:

  File "c:\users\gauth\appdata\local\programs\python\python37\lib\site-packages\_pyinstaller_hooks_contrib\hooks\stdhooks\hook-IPython.py", line 16, in <module>
    from PyInstaller.compat import modname_tkinter, is_win, is_darwin
ImportError: cannot import name 'modname_tkinter' from 'PyInstaller.compat' (c:\users\gauth\appdata\local\programs\python\python37\lib\site-packages\PyInstaller\compat.py)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "c:\users\gauth\appdata\local\programs\python\python37\lib\runpy.py", line 193, in _run_module_as_main
    "__main__", mod_spec)
  File "c:\users\gauth\appdata\local\programs\python\python37\lib\runpy.py", line 85, in _run_code
    exec(code, run_globals)
  File "C:\Users\gauth\AppData\Local\Programs\Python\Python37\Scripts\pyinstaller.exe\__main__.py", line 7, in <module>
  File "c:\users\gauth\appdata\local\programs\python\python37\lib\site-packages\PyInstaller\__main__.py", line 178, in run
    run_build(pyi_config, spec_file, **vars(args))
  File "c:\users\gauth\appdata\local\programs\python\python37\lib\site-packages\PyInstaller\__main__.py", line 59, in run_build
    PyInstaller.building.build_main.main(pyi_config, spec_file, **kwargs)
  File "c:\users\gauth\appdata\local\programs\python\python37\lib\site-packages\PyInstaller\building\build_main.py", line 845, in main
    build(specfile, distpath, workpath, clean_build)
  File "c:\users\gauth\appdata\local\programs\python\python37\lib\site-packages\PyInstaller\building\build_main.py", line 767, in build
    exec(code, spec_namespace)
  File "H:\Mon Drive\Phonebot\Phonebot_debug3\PhoneBot.spec", line 20, in <module>
    noarchive=False,
  File "c:\users\gauth\appdata\local\programs\python\python37\lib\site-packages\PyInstaller\building\build_main.py", line 319, in __init__
    self.__postinit__()
  File "c:\users\gauth\appdata\local\programs\python\python37\lib\site-packages\PyInstaller\building\datastruct.py", line 173, in __postinit__
    self.assemble()
  File "c:\users\gauth\appdata\local\programs\python\python37\lib\site-packages\PyInstaller\building\build_main.py", line 487, in assemble
    self.graph.process_post_graph_hooks(self)
  File "c:\users\gauth\appdata\local\programs\python\python37\lib\site-packages\PyInstaller\depend\analysis.py", line 326, in process_post_graph_hooks
    module_hook.post_graph(analysis)
  File "c:\users\gauth\appdata\local\programs\python\python37\lib\site-packages\PyInstaller\depend\imphook.py", line 398, in post_graph
    self._load_hook_module()
  File "c:\users\gauth\appdata\local\programs\python\python37\lib\site-packages\PyInstaller\depend\imphook.py", line 364, in _load_hook_module
    raise ImportErrorWhenRunningHook(self.hook_module_name, self.hook_filename)
PyInstaller.exceptions.ImportErrorWhenRunningHook: Failed to import module __PyInstaller_hooks_0_IPython required by hook for module c:\users\gauth\appdata\local\programs\python\python37\lib\site-packages\_pyinstaller_hooks_contrib\hooks\stdhooks\hook-IPython.py. Please check whether module __PyInstaller_hooks_0_IPython actually exists and whether the hook is compatible with your version of c:\users\gauth\appdata\local\programs\python\python37\lib\site-packages\_pyinstaller_hooks_contrib\hooks\stdhooks\hook-IPython.py: You might want to read more about hooks in the manual and provide a pull-request to improve PyInstaller.

H:\Mon Drive\Phonebot\Phonebot_debug3>pyinstaller --onefile -F --uac-admin --icon="favicon_phonebot.ico" --exclude-module modname_tkinter --debug=all PhoneBot.py

奇怪的是我没有在我的代码中使用 Tkinter。谁能帮我解决这个问题?

谢谢

pip install -U pyinstaller-hooks-contrib

我使用的是 pyinstaller-hooks-contrib 的过时版本 - IPython 钩子中的违规导入行已在一年前删除。

帮我把kivy lib更新到最新版本