Search code examples
pythonmysqlopencvtkinterface-recognition

converting .py file to .exe file


we have a face recognition module imported in our .py file, how to convert that .py file into executable file? and also we have some .txt files for which we gave project path itself. How to change that local path to global path and to convert to executable file?


Solution

  • The steps for an executable file is as simple as below - Install cx_freeze and then create a file setup.py and paste the following contents -

    build_exe_options = {"includes": ["tkinter"]}
    base = None
    if sys.platform == "win32":
        base = "Win32GUI"
    
    from cx_Freeze import setup, Executable 
    
    setup(name = "<name-of-executable-file.exe>" , 
    version = "<your-version-number>" , 
    description = "<suitable-description>" ,
    options={"build_exe": build_exe_options},
    executables = [Executable("<your-python-file.py>", base=base)]) 
    

    Run python setup.py build in your terminal.