Question

I plan to use PyInstaller to create a stand-alone python executable. PythonInstaller comes with built-in support for UPX and uses it to compress the executable but they are still really huge (about 2,7 mb).

Is there any way to create even smaller Python executables? For example using a shrinked python.dll or something similiar?

Was it helpful?

Solution

If you recompile pythonxy.dll, you can omit modules that you don't need. Going by size, stripping off the unicode database and the CJK codes creates the largest code reduction. This, of course, assumes that you don't need these. Remove the modules from the pythoncore project, and also remove them from PC/config.c

OTHER TIPS

Using a earlier Python version will also decrease the size considerably if your really needing a small file size. I don't recommend using a very old version, Python2.3 would be the best option. I got my Python executable size to 700KB's! Also I prefer Py2Exe over Pyinstaller.

You can't go too low in size, because you obviously need to bundle the Python interpreter in, and only that takes a considerable amount of space.

I had the same concerns once, and there are two approaches:

  1. Install Python on the computers you want to run on and only distribute the scripts
  2. Install Python in the internal network on some shared drive, and rig the users' PATH to recognize where Python is located. With some installation script / program trickery, users can be completely oblivious to this, and you'll get to distribute minimal applications.
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top