2

I'd like to create an executable with pyinstaller for my colleagues. My first attempt (on anaconda python 3.6) causes so much crap to get included the executable is over 200mb in size. For a 20 line script that only needs numpy because pandas requires it. I'm indexing an excel file, it's not rocket surgery.

I got a venv going, installed the required modules, but the numpy version you get from pypi (3.6, amd64) won't import on windows due to a dll importing error. So I got the precompiled .whl that comes with the MKL libraries; and when I install that and pyinstall -F script the exe comes out at a hefty 166mb. Ideally I'd want to get the size down to maybe 30-50mb.

I've been looking into ways to get rid of the MKL but I don't feel like I've sussed it. Any advice would be greatly appreciated!

AMC
  • 2,642
  • 7
  • 13
  • 35
Rafaël Dera
  • 399
  • 2
  • 9
  • I managed to circumvent the need for numpy in the 'client' by having a second script to pre-process the data and spit it out as a pickle in a static location. The 'clients' only need to read the pickle over the network so it loads more quickly and the exe is only about 6Mb. It feels like cheating; but it does work pretty well. – Rafaël Dera Sep 05 '17 at 14:36
  • I have a similar problem. I made a separate env. Then installed pyinstaller and also pandas in it. The size reduced from 326 MB to 212 MB!!! I don't know what to do :( – mah65 Dec 27 '19 at 03:32
  • The issue is the MKL (intel mathkernel library) which is huge! I'm sure it's good at what it does but I'd be happy to sacrifice a bit of speed to have the installer be a more reasonable size. There used to be a version that didn't have mathkernel but I can't seem to find it anymore... Please write an answer if you can find any solutions. – Rafaël Dera Dec 28 '19 at 18:15
  • 1
    Found the solution. Check here: https://stackoverflow.com/questions/59524507/how-to-make-pyinstaller-not-use-anaconda-and-build-a-small-size-exe-file?noredirect=1#comment105220619_59524507 – mah65 Jan 14 '20 at 02:47
  • Very interesting! I'll have to try that if I ever do anything like it again. – Rafaël Dera Jan 14 '20 at 12:12
  • Does this answer your question? [PyInstaller with Pandas creates over 500 MB exe](https://stackoverflow.com/questions/43886822/pyinstaller-with-pandas-creates-over-500-mb-exe) – AMC Apr 16 '20 at 00:25

1 Answers1

1

You're not the only one to have noticed the massive size of MKL when packaging with pyinstaller!

While it is more focused on conda-forge, here is an informative GitHub issue: https://github.com/conda-forge/numpy-feedstock/issues/84.

It links to a post right here on SO: PyInstaller with Pandas creates over 500 MB exe.

AMC
  • 2,642
  • 7
  • 13
  • 35