I\'m building a Python application and don\'t want to force my clients to install Python and modules.
So, is there a way to compile a Python script to be a standalone
Using PyInstaller, I found a better method using shortcut to the .exe rather than making --onefile
. Anyway, there are probably some data files around and if you're running a site-based app then your program depends on HTML, JavaScript, and CSS files too. There isn't any point in moving all these files somewhere... Instead what if we move the working path up?
Make a shortcut to the EXE file, move it at top and set the target and start-in paths as specified, to have relative paths going to dist\folder:
Target: %windir%\system32\cmd.exe /c start dist\web_wrapper\web_wrapper.exe
Start in: "%windir%\system32\cmd.exe /c start dist\web_wrapper\"
We can rename the shortcut to anything, so renaming to "GTFS-Manager".
Now when I double-click the shortcut, it's as if I python
-ran the file! I found this approach better than the --onefile
one as:
python3 myfile.py
) and Windows (double-click the shortcut).Oh, remember to delete off the build folder after building. It will save on size.