title: exe generated by py2exe and pyinstaller not working
body: <p>I wrote a screenshot program using python and wanted to compile it as <code>.exe</code> file. So I tried with both <code>py2exe</code> and <code>pyinstaller</code>.</p>
  
  <p>My python version is <code>2.7.14</code>, 32bit. I use Windows 10. I also use virtual environment in this project. </p>
  
  <p>My code for the screenshot program is like below. I run it by <code>python screenshot.py</code> and it take a screenshot of my screen and stored it inside the save directory.</p>
  
  <pre><code>from PIL import Image
  import pyscreenshot as ImageGrab
  import time
  
  
  time.sleep(3)
  
  
  save_dir = "C:/Users/ling/Downloads/test/"
  
  def grab():
      im = ImageGrab.grab()
      im.save(save_dir + "screenshot.png")
  
  
  if __name__ == "__main__":
      grab()
  </code></pre>
  
  <h1>pyinstaller</h1>
  
  <p>for <code>pyinstaller</code>, I simply install it using <code>pip install pyinstaller</code>. The version that was installed -> <code>3.3.1</code>. Note that I install this package inside virtual environment.</p>
  
  <p>I compiled the program by running <code>pyinstaller --onefile screenshot.py</code>. It generated an executable <code>screenshot.exe</code>. When I run the executable, no screenshot was taken.</p>
  
  <h1>py2exe</h1>
  
  <p>For installing <code>py2exe</code>, since there is some issue regarding installing it on Windows computer running python 2, I followed the tutorial from this <a href="https://simpletutorials.com/c/2081/Install+Py2exe+for+Python+2.7+on+Windows" rel="nofollow noreferrer">link</a></p>
  
  <p>I create <code>setup.py</code> to compiled <code>screenshot.py</code> as <code>screenshot.exe</code>. Below is the code for <code>setup.py</code></p>
  
  <pre><code>from distutils.core import setup
  import py2exe
  
  setup(
        console=[{'script':'screenshot.py'}],
        options = {
              'py2exe': {
                  'includes': ['PIL','pyscreenshot','time'],
                  'bundle_files': 1, 'compressed': True
               }
        },
        zipfile = None
  )
  </code></pre>
  
  <p>I run it by using <code>python setup.py py2exe</code>. It generated a single executable file. When I run this file, the result is same as <code>pyinstaller</code>. There is no screenshot taken.</p>
  
  <p>I need help on why does the <code>screenshot.exe</code> not working. Am I missing something?</p>
  
  <p>Thank you for your help.</p>