question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Not including tkinter for standalone exe

See original GitHub issue

Cannot create standalone exe for scripts using tkinter.

  • nuitka pip installation
  • Compiler installed VS 2017
  • output of nuitka generation:
Microsoft Windows [Version 10.0.16299.665]                                          
                                                                                    
Jorj@ARRAKIS C:\Users\Jorj\Desktop\test                                             
$ python -m nuitka --portable test.py                                               
                                                                                    
Jorj@ARRAKIS C:\Users\Jorj\Desktop\test                                             
$ python -m nuitka --version                                                        
0.5.33                                                                              
Python: 3.7.0 (v3.7.0:1bf9cc5093, Jun 27 2018, 04:59:51) [MSC v.1914 64 bit (AMD64)]
Executable: C:\Users\Jorj\AppData\Local\Programs\Python\Python37\python.exe         
OS: Windows                                                                         
Arch: x86_64                                                                        
  • Script:
import tkinter
root = tkinter.Tk()
root.bbox()
root.bell()

Output when running test.exe:

Jorj@ARRAKIS C:\Users\Jorj\Desktop\test\test.dist                                                                                                                                                                                              
$ test.exe                                                                                                                                                                                                                                     
Traceback (most recent call last):                                                                                                                                                                                                             
 File "C:\Users\Jorj\Desktop\test\test.dist\test.py", line 2, in <module>                                                                                                                                                                     
  File "C:\Users\Jorj\Desktop\test\test.dist\tkinter\__init__.py", line 2020, in __init__                                                                                                                                                      
_tkinter.TclError: Can't find a usable init.tcl in the following directories:                                                                                                                                                                  
    {C:\Users\Jorj\AppData\Local\Programs\Python\Python37\tcl} C:/Users/Jorj/AppData/Local/Programs/Python/Python37/tcl8.6 C:/Users/Jorj/Desktop/test/lib/tcl8.6 C:/Users/Jorj/Desktop/test/lib/tcl8.6 C:/Users/Jorj/Desktop/lib/tcl8.6 C:/User
s/Jorj/Desktop/test/library C:/Users/Jorj/Desktop/library C:/Users/Jorj/Desktop/tcl8.6.8/library C:/Users/Jorj/tcl8.6.8/library                                                                                                                
                                                                                                                                                                                                                                               
                                                                                                                                                                                                                                               
                                                                                                                                                                                                                                               
This probably means that Tcl wasn't installed properly. 

Problem goes away when I (e.g.) copy the two directories C:\Users\Jorj\AppData\Local\Programs\Python\Python37\tcl\tcl8.6 and C:\Users\Jorj\AppData\Local\Programs\Python\Python37\tcl\tk8.6 side-by side in a common directory called lib on the same level as test.dist.

What am I missing / doing wrong?

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:61 (56 by maintainers)

github_iconTop GitHub Comments

1reaction
deajancommented, Jan 17, 2019

@JorjMcKie Indeed, I’m just concerned about using opensource which may be freely redistributed, hence trying to avoir Microsoft tools here. I think the results are the same:

objdump -p c:\Python37-32\python37.dll | findstr "DLL Name:"
        DLL Name: VERSION.dll
        DLL Name: SHLWAPI.dll
        DLL Name: WS2_32.dll
        DLL Name: KERNEL32.dll
        DLL Name: ADVAPI32.dll
        DLL Name: VCRUNTIME140.dll
        DLL Name: api-ms-win-crt-runtime-l1-1-0.dll
        DLL Name: api-ms-win-crt-math-l1-1-0.dll
        DLL Name: api-ms-win-crt-locale-l1-1-0.dll
        DLL Name: api-ms-win-crt-string-l1-1-0.dll
        DLL Name: api-ms-win-crt-stdio-l1-1-0.dll
        DLL Name: api-ms-win-crt-convert-l1-1-0.dll
        DLL Name: api-ms-win-crt-time-l1-1-0.dll
        DLL Name: api-ms-win-crt-environment-l1-1-0.dll
        DLL Name: api-ms-win-crt-process-l1-1-0.dll
        DLL Name: api-ms-win-crt-heap-l1-1-0.dll
        DLL Name: api-ms-win-crt-conio-l1-1-0.dll
        DLL Name: api-ms-win-crt-filesystem-l1-1-0.dll

Yet better, I found a pythonic way to do so

import pefile
import sys

def get_dependency(filename):
    deps = []
    pe = pefile.PE(filename)
    for imp in pe.DIRECTORY_ENTRY_IMPORT:
        deps.append(imp.dll.decode())
    return deps

deps = get_dependency(sys.argv[1])
for dep in deps:
	print(dep)

Which produces the same result, without needing subprocess. Going to tweak Standalone.py to use this so we won’t have any more …dependencies (pun intended).

1reaction
JorjMcKiecommented, Jan 17, 2019

@deajan maybe I am missing a point, but how about using dumbin.exe (Visual Studio) on Windows? Sample output (redirectable to file, tons of other options available)

dumpbin.exe /DEPENDENTS C:\Users\Jorj\AppData\Local\Programs\Python\Python37\python37.dll

Dump of file C:\Users\Jorj\AppData\Local\Programs\Python\Python37\python37.dll

File Type: DLL

  Image has the following dependencies:

    VERSION.dll
    SHLWAPI.dll
    WS2_32.dll
    KERNEL32.dll
    ADVAPI32.dll
    VCRUNTIME140.dll
    api-ms-win-crt-runtime-l1-1-0.dll
    api-ms-win-crt-math-l1-1-0.dll
    api-ms-win-crt-locale-l1-1-0.dll
    api-ms-win-crt-string-l1-1-0.dll
    api-ms-win-crt-stdio-l1-1-0.dll
    api-ms-win-crt-convert-l1-1-0.dll
    api-ms-win-crt-time-l1-1-0.dll
    api-ms-win-crt-environment-l1-1-0.dll
    api-ms-win-crt-process-l1-1-0.dll
    api-ms-win-crt-heap-l1-1-0.dll
    api-ms-win-crt-conio-l1-1-0.dll
    api-ms-win-crt-filesystem-l1-1-0.dll
<...>
Read more comments on GitHub >

github_iconTop Results From Across the Web

Convert tkinter to EXE - python - Stack Overflow
1. your EXE file is self-uncompressing ZIP file - when you start program then system uncompresses it to random folder and it doesn't...
Read more >
Converting Tkinter program to exe file - Tutorialspoint
Converting Tkinter program to exe file - Let us suppose that we want to create a standalone app (executable application) using tkinter.
Read more >
Packaging Tkinter applications for Windows, with PyInstaller ...
toc is non existent 10015 INFO: Building EXE from EXE-00.toc 10015 INFO: Copying bootloader EXE to C:\Users\Martin\pyinstaller\tkinter\basic\ ...
Read more >
Executable GUI with Python. using Tkinter and Pyinstaller
In this project, we will be building a GUI (graphical user interface) using Tkinter in python. Tkinter is a python's standard GUI tool...
Read more >
What PyInstaller Does and How It Does It
You distribute the bundle as a folder or file to other people, and they can execute your program. To your users, the app...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found