How to compile python 3.4.3 script to exe? -


how compile python 3.4.3 script module tkinter , ttk self-executable exe (standalone)? (py2exe, pyinstaller, freeze doesn't work.) suggestions? thank you

what is

  1. download portable python
  2. create file in other language can compiled exe
  3. make executable call portable python python file.

structure:

application_folder    # folder in +--my_python_folder   # folder python files in  |  +--my_program.py   # python file want start +--portable python 3  # python version use +--program.exe        # compiled program 

the c++ source code:

// based on https://msdn.microsoft.com/en-us/library/ms682425%28vs.85%29.aspx  #include <windows.h> #include <stdio.h> #include <tchar.h>  int _tmain( int argc, tchar *argv[] ) {     startupinfo si;     process_information pi;     // choose between pythonw.exe , python.exe     tchar command[] = "\"portable python 3\\app\\pythonw.exe\" \"my_program.py\"";     // directory start python program in     tchar directory[] = "my_python_folder";      zeromemory( &si, sizeof(si) );     si.cb = sizeof(si);     zeromemory( &pi, sizeof(pi) );      // start child process.      if( !createprocess( null,   // no module name (use command line)         command,        // command line         null,           // process handle not inheritable         null,           // thread handle not inheritable         false,          // set handle inheritance false         0,              // no creation flags         null,           // use parent's environment block         directory,           // use parent's starting directory          &si,            // pointer startupinfo structure         &pi )           // pointer process_information structure     )      {         printf( "createprocess failed (%d).\n", getlasterror() );         return 1;     } /*     // wait until child process exits.     waitforsingleobject( pi.hprocess, infinite );     // close process , thread handles.      closehandle( pi.hprocess );     closehandle( pi.hthread ); */     return 0; } 

you can compile file devc++.

evaluation

pros:

  • an other way it.

cons:

  • needs whole portable python.
  • no command line arguments passed.
  • you can .bat file , works, too.
  • the current working directory different caller's one.

Comments

Popular posts from this blog

python - Healpy: From Data to Healpix map -

c - Bitwise operation with (signed) enum value -

xslt - Unnest parent nodes by child node -