ImportError: No module named 'tkinter' after pyInstaller

前端 未结 3 1251
孤城傲影
孤城傲影 2021-01-14 10:07

I want to do an executable, but ervery time I run the .exe it writes ImportError: No module named \'tkinter\', and all I read on Stackowerflow do not help me !

相关标签:
3条回答
  • 2021-01-14 10:14

    The problem is that pyinstaller won't see second level imports. So if you import module A, pyinstaller sees this. But any additional module that is imported in A will not be seen.

    There is no need to change anything in your python scripts. You can directly add the missing imports to the spec file (prog.spec in your case). Just change the following line:

    hiddenimports=[],
    

    to

    hiddenimports=["tkinter"],
    

    After that run pyinstaller prog.spec to create the prog.exe.

    0 讨论(0)
  • 2021-01-14 10:18

    FINALLY WORKED FOR pyinstaller -F --hidden-import=tkinter --hidden-import=tkinter.filedialog prog.py Thanks a lot !!!

    0 讨论(0)
  • 2021-01-14 10:36

    You should use hidden import
    pyinstaller eulersolver.py --hidden-import=tkinter -y

    0 讨论(0)
提交回复
热议问题