3

I have compiled the exe of a .py file but the problem is that it is 200mb+ I would like to remove useless packages (for instance scipy that I am not using).

Still I have not clear the proper syntax of PyInstaller.

Let's start from the beginning...usually I do on cmd:

cd myFolder
C:\Python27\Scripts\Pyinstaller.exe MyFile.py 

and it gives me the exe file in the dist folder.

If I want to set some configuration which is the proper way?

C:\Python27\Scripts\Pyinstaller.exe MyFile.py Config.py

or

C:\Python27\Scripts\Pyinstaller.exe Config.py

because online I found both of them but I could not distinguish.

If it is the last one I tried to run:

lock_cipher = None
a = Analysis(['Main.py'],
     pathex=['C:\Users\myname\Desktop\myFolder'],
     binaries=None,
     datas=None,
     hiddenimports=[],
     hookspath=None,
     runtime_hooks=None,
     excludes=None,
     cipher=block_cipher)
a.binaries = [x for x in a.binaries if not x[0].startswith("scipy")]
pyz = PYZ(a.pure, a.zipped_data,
     cipher=block_cipher)
exe = EXE(pyz)
coll = COLLECT(exe)

But it does not work. Where am I wrong?

Thegamer23
  • 537
  • 1
  • 8
  • 20

1 Answers1

5

My suggestion is that you use a virtual env containing only the required modules. It is a better development practice.

Also, you can use --exclude-module flag to list all the modules you want to exclude. (Pyinstaller automatically includes unneeded modules)

Tiago Martins Peres
  • 14,289
  • 18
  • 86
  • 145
  • Thanks do you have a good guide for what concerns point 1 and the command --exclude-module is to be included in cmd? There is no way to fix it with thecode I have posted? Thanks a lot – Thegamer23 Jul 11 '17 at 10:19
  • you can see the answer for that in here: https://pythonhosted.org/PyInstaller/usage.html – Tiago Martins Peres Jul 11 '17 at 10:24