Skip to content
Advertisement

How can I create the minimum size executable with pyinstaller?

I am on Windows 10, I have anaconda installed but I want to create an executable independently in a new, clean minimal environment using python 3.5. So I did some tests:

TEST1: I created a python script test1.py in the folder testenv with only:

JavaScript

Then I created the environment, installed pyinstaller and created the executable

JavaScript

And it creates my test1.exe of about 6 Mb

TEST 2: I modified test1.py as follows:

JavaScript

I installed pandas in the environment and created the new executable:

JavaScript

Ant it creates my test1.exe which is now of 230 Mb!!!

if I run the command

JavaScript

when I am running pyinstaller I get some messages I do not understand, for example:

JavaScript

Also I am getting messages about matplotlib and other modules that have nothing to do with my code, for example:

JavaScript

I know there are some related questions: Reducing size of pyinstaller exe, size of executable using pyinstaller and numpy but I could not solve the problem and I am afraid I am doing something wrong with respect to anaconda.

So my questions are: what am I doing wrong? can I reduce the size of my executable?

Advertisement

Answer

The problem is that you should not be using a virtual environment and especially not anaconda. Please download default python 32 bit and use only necessary modules. Then follow the steps provided in the links, this should definitely fix it.

Although you created a virtual env, are you sure your spec file is not linking to old Anaconda entries?

If all this fails, then submit a bug as this is very strange.

User contributions licensed under: CC BY-SA
5 People found this is helpful
Advertisement