12

I am trying to create a .exe from a very simple script that I have written. The script only include glob and pandas. But pyinstaller is including matplotlib,numpy,scipy,qt4,ipython, and a bunch of other stuff. The .exe won't run because there is an error with matplotlib, but I don't even need matplotlib. What am I doing wrong to make pyinstaller not recognize that only glob and pandas are needed?

I have manually excluded scipy,matplotlib,PyQt4,and iPython and the .exe is still 160mb!

P.S. I'm doing this in winpython with python 3.4.

Edit: With a little further testing I have narrowed this down to Pandas. Even a script that only consists of:

import pandas

will create a dist folder that is 460MB or a single file .exe that is 182MB. What is the easiest way that I can find out which modules are being imported so that I can properly exclude all of them?

Edit2: I have tried making a hook-pandas.py file that contains:

excludedhooks=['scipy','matplotlib','PIL','cython','PyQt4','zmq']

The console output indicates that imports are being removed due to the hook file, but tons of files from these modules still end up in the dist folder.

I have also tried excluding these modules in the .spec file as well as in the console using --exclude-module but the files from those modules still show up.

nickexists
  • 404
  • 1
  • 4
  • 12
  • http://stackoverflow.com/questions/4890159/python-excluding-modules-pyinstaller/17595149#17595149 have a look – Taylan Apr 17 '16 at 16:45
  • So i need to go through and manually exclude everything that I don't need? Why would it assume that I was all those modules included? – nickexists Apr 17 '16 at 17:24
  • Well I do not know that, but I guess the answer is written in the PyInstaller's official manual. – Taylan Apr 17 '16 at 18:38
  • Some of that stuff is definitely necessary. Pandas is built upon NumPy, so you'll definitely need NumPy. – user2357112 Apr 17 '16 at 18:54
  • Wild guess, but don't you have some unnecessary big files(e.g. binaries) in your app folder? PyInstaller may take those into the package too. What's included is in console output afaik. – Peter Badida Apr 17 '16 at 22:29
  • Bloat is even worse under Anaconda. [Related Git discussion here](https://github.com/pyinstaller/pyinstaller/issues/1694). – feetwet Apr 07 '18 at 20:47

2 Answers2

2

Pyinstaller may have figured those dependencies from your current ones. If you're sure, use --exclude-module flag to list all the modules you want to exclude.

http://pythonhosted.org/PyInstaller/#general-options

Pandemonium
  • 7,724
  • 3
  • 32
  • 51
2

Not sure if this really counts as a solutions. But by ignoring winpython all together and using a standard installation of python that only had pip installs of pyinstaller and pandas added to it I was easily able generate a functional .exe that was 18MB. I guess it had something to do with winpython.

nickexists
  • 404
  • 1
  • 4
  • 12