title: How can I create the minimum size executable with pyinstaller?
body: <p>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: </p>
  
  <p>TEST1: 
  I created a python script test1.py in the folder testenv with only:</p>
  
  <pre><code>print('Hello World')
  </code></pre>
  
  <p>Then I created the environment, installed pyinstaller and created the executable</p>
  
  <pre><code>D:\testenv&gt; python -m venv venv_test
  ...
  D:\testenv\venv_test\Scripts&gt;activate.bat
  ...
  (venv_test) D:\testenv&gt;pip install pyinstaller
  (venv_test) D:\testenv&gt;pyinstaller --clean -F test1.py
  </code></pre>
  
  <p>And it creates my test1.exe of about 6 Mb</p>
  
  <p>TEST 2: I modified test1.py as follows:</p>
  
  <pre><code>import pandas as pd
  print('Hello World')  
  </code></pre>
  
  <p>I installed pandas in the environment and created the new executable:</p>
  
  <pre><code>(venv_test) D:\testenv&gt;pip install pandas
  (venv_test) D:\testenv&gt;pyinstaller --clean -F test1.py
  </code></pre>
  
  <p>Ant it creates my test1.exe which is now of <strong>230 Mb</strong>!!! </p>
  
  <p>if I run the command </p>
  
  <pre><code>(venv_test) D:\testenv&gt;python -V
  Python 3.5.2 :: Anaconda custom (64-bit)
  </code></pre>
  
  <p>when I am running pyinstaller I get some messages I do not understand, for example: </p>
  
  <pre><code>INFO: site: retargeting to fake-dir 'c:\\users\\username\\appdata\\local\\continuum\\anaconda3\\lib\\site-packages\\PyInstaller\\fake-modules'
  </code></pre>
  
  <p>Also I am getting messages about matplotlib and other modules that have nothing to do with my code, for example: </p>
  
  <pre><code>INFO:   Matplotlib backend "pdf": added
  INFO:   Matplotlib backend "pgf": added
  INFO:   Matplotlib backend "ps": added
  INFO:   Matplotlib backend "svg": added
  </code></pre>
  
  <p>I know there are some related questions: 
  <a href="https://stackoverflow.com/questions/47692213/reducing-size-of-pyinstaller-exe">Reducing size of pyinstaller exe</a>, <a href="https://stackoverflow.com/questions/47769904/size-of-executable-using-pyinstaller-and-numpy">size of executable using pyinstaller and numpy</a>
  but I could not solve the problem and I am afraid I am doing something wrong with respect to anaconda.  </p>
  
  <p>So my questions are:
  what am I doing wrong? can I reduce the size of my executable?</p>