title: Unable to run Kivy application compiled with Pyinstaller
body: <p>I am unable to run a Kivy application compiled with pyinstaller. Here is the output:</p>
  
  <pre><code>[INFO   ] [Logger      ] Record log in C:\Users\jakub\.kivy\logs\kivy_18-05-
  
  11_28.txt
  [INFO   ] [Kivy        ] v1.10.0
  [INFO   ] [Python      ] v3.6.5 (v3.6.5:f59c0932b4, Mar 28 2018, 16:07:46) [MSC v.1900 32 bit (Intel)]
  [INFO   ] [Factory     ] 194 symbols loaded
  [INFO   ] [Image       ] Providers: img_tex, img_dds, img_sdl2, img_pil, img_gif (img_ffpyplayer ignored)
  [INFO   ] [OSC         ] using &lt;thread&gt; for socket
  [INFO   ] [Window      ] Provider: sdl2
  [INFO   ] [GL          ] Using the "OpenGL" graphics system
  [INFO   ] [GL          ] GLEW initialization succeeded
  [INFO   ] [GL          ] Backend used &lt;glew&gt;
  [INFO   ] [GL          ] OpenGL version &lt;b'4.0.0 - Build 10.18.10.4885'&gt;
  [INFO   ] [GL          ] OpenGL vendor &lt;b'Intel'&gt;
  [INFO   ] [GL          ] OpenGL renderer &lt;b'Intel(R) HD Graphics 4000'&gt;
  [INFO   ] [GL          ] OpenGL parsed version: 4, 0
  [INFO   ] [GL          ] Shading version &lt;b'4.00 - Build 10.18.10.4885'&gt;
  [INFO   ] [GL          ] Texture max size &lt;16384&gt;
  [INFO   ] [GL          ] Texture max units &lt;16&gt;
  [WARNING] [Image       ] Unable to load image &lt;C:\Users\jakub\AppData\Local\Temp\_MEI90522\kivy_install\data\glsl\default.png&gt;
  [CRITICAL] [Window      ] Unable to find any valuable Window provider.
  sdl2 - Exception: SDL2: Unable to load image
    File "site-packages\kivy\core\__init__.py", line 67, in core_select_lib
    File "site-packages\kivy\core\window\window_sdl2.py", line 140, in __init__
    File "site-packages\kivy\core\window\__init__.py", line 899, in __init__
    File "site-packages\kivy\core\window\window_sdl2.py", line 291, in create_window
    File "site-packages\kivy\core\window\__init__.py", line 1051, in create_window
    File "kivy\graphics\instructions.pyx", line 758, in kivy.graphics.instructions.RenderContext.__init__ (kivy\graphics\instructions.c:12580)
    File "site-packages\kivy\core\image\__init__.py", line 538, in __init__
    File "site-packages\kivy\core\image\__init__.py", line 734, in _set_filename
    File "site-packages\kivy\core\image\__init__.py", line 435, in load
    File "site-packages\kivy\core\image\__init__.py", line 201, in __init__
    File "site-packages\kivy\core\image\img_sdl2.py", line 41, in load
  
  [INFO   ] [Text        ] Provider: sdl2
  [CRITICAL] [App         ] Unable to get a Window, abort.
   Exception ignored in: 'kivy.properties.dpi2px'
   Traceback (most recent call last):
     File "site-packages\kivy\utils.py", line 496, in __get__
     File "site-packages\kivy\metrics.py", line 174, in dpi
     File "site-packages\kivy\base.py", line 127, in ensure_window
   SystemExit: 1
  [CRITICAL] [App         ] Unable to get a Window, abort.
   Exception ignored in: 'kivy.properties.dpi2px'
   Traceback (most recent call last):
     File "site-packages\kivy\utils.py", line 496, in __get__
     File "site-packages\kivy\metrics.py", line 174, in dpi
     File "site-packages\kivy\base.py", line 127, in ensure_window
   SystemExit: 1
  [CRITICAL] [App         ] Unable to get a Window, abort.
   Exception ignored in: 'kivy.properties.dpi2px'
   Traceback (most recent call last):
     File "site-packages\kivy\utils.py", line 496, in __get__
     File "site-packages\kivy\metrics.py", line 174, in dpi
     File "site-packages\kivy\base.py", line 127, in ensure_window
   SystemExit: 1
  [CRITICAL] [App         ] Unable to get a Window, abort.
   Exception ignored in: 'kivy.properties.dpi2px'
   Traceback (most recent call last):
     File "site-packages\kivy\utils.py", line 496, in __get__
     File "site-packages\kivy\metrics.py", line 174, in dpi
     File "site-packages\kivy\base.py", line 127, in ensure_window
   SystemExit: 1
  [CRITICAL] [App         ] Unable to get a Window, abort.
   Exception ignored in: 'kivy.properties.dpi2px'
   Traceback (most recent call last):
     File "site-packages\kivy\utils.py", line 496, in __get__
     File "site-packages\kivy\metrics.py", line 174, in dpi
     File "site-packages\kivy\base.py", line 127, in ensure_window
   SystemExit: 1
  [CRITICAL] [App         ] Unable to get a Window, abort.
   Exception ignored in: 'kivy.properties.dpi2px'
   Traceback (most recent call last):
     File "site-packages\kivy\utils.py", line 496, in __get__
     File "site-packages\kivy\metrics.py", line 174, in dpi
     File "site-packages\kivy\base.py", line 127, in ensure_window
   SystemExit: 1
   Traceback (most recent call last):
     File "main.py", line 33, in &lt;module&gt;
   AttributeError: 'NoneType' object has no attribute 'set_icon'
  [11960] Failed to execute script main
  </code></pre>
  
  <p>This is my spec file:</p>
  
  <pre><code># -*- mode: python -*-
  
  block_cipher = None
  
  
  a = Analysis(['main.py'],
               pathex=['C:\\Users\\jakub\\Desktop\\python\\Datelbot'],
               binaries=[('img/icon.ico', 'img')],
               datas=[],
               hiddenimports=[],
               hookspath=[],
               runtime_hooks=[],
               excludes=[],
               win_no_prefer_redirects=False,
               win_private_assemblies=False,
               cipher=block_cipher)
  pyz = PYZ(a.pure, a.zipped_data,
               cipher=block_cipher)
  exe = EXE(pyz,
            a.scripts,
            a.binaries,
            a.zipfiles,
            a.datas,
            name='Datelbot.exe',
            debug=False,
            strip=False,
            upx=True,
            runtime_tmpdir=None,
            console=True , version='version.py', icon='img\\icon.ico')
  </code></pre>
  
  <p>My <code>build.bat</code>:</p>
  
  <pre><code>pyinstaller^
  --onefile^
  --add-binary img/icon.ico;img^
  --icon img/icon.ico^
  --version-file version.py^
  --name Datelbot.exe^
  datelbot.exe.spec
  </code></pre>
  
  <p>And this is the PyInstaller output:</p>
  
  <pre><code>C:\Users\jakub\Desktop\python\Datelbot&gt;pyinstaller --onefile --add-binary img/icon.ico;img --icon img/icon.ico --version-file version.py --name Datelbot.exe datelbot.exe.spec
  92 INFO: PyInstaller: 3.3.1
  92 INFO: Python: 3.6.5
  93 INFO: Platform: Windows-10-10.0.17666-SP0
  94 INFO: UPX is not available.
  [INFO   ] [Logger      ] Record log in C:\Users\jakub\.kivy\logs\kivy_18-05-11_32.txt
  119 INFO: [Logger      ] Record log in C:\Users\jakub\.kivy\logs\kivy_18-05-11_32.txt
  [INFO   ] [Kivy        ] v1.10.0
  116 INFO: [Kivy        ] v1.10.0
  [INFO   ] [Python      ] v3.6.5 (v3.6.5:f59c0932b4, Mar 28 2018, 16:07:46) [MSC v.1900 32 bit (Intel)]
  120 INFO: [Python      ] v3.6.5 (v3.6.5:f59c0932b4, Mar 28 2018, 16:07:46) [MSC v.1900 32 bit (Intel)]
  123 INFO: Extending PYTHONPATH with paths
  ['C:\\Users\\jakub\\Desktop\\python\\Datelbot',
   'C:\\Users\\jakub\\Desktop\\python\\Datelbot']
  123 INFO: checking Analysis
  164 INFO: Building because C:\Users\jakub\Desktop\python\Datelbot\main.py changed
  164 INFO: Initializing module dependency graph...
  168 INFO: Initializing module graph hooks...
  170 INFO: Analyzing base_library.zip ...
  5353 INFO: running Analysis out00-Analysis.toc
  5356 INFO: Adding Microsoft.Windows.Common-Controls to dependent assemblies of final executable
    required by c:\program files (x86)\python36-32\python.exe
  6973 INFO: Caching module hooks...
  6982 INFO: Analyzing main.py
  9667 INFO: Processing pre-find module path hook   distutils
  11867 INFO: Processing pre-find module path hook   site
  11868 INFO: site: retargeting to fake-dir 'c:\\program files (x86)\\python36-32\\lib\\site-packages\\PyInstaller\\fake-modules'
  17725 INFO: Loading module hooks...
  17726 INFO: Loading module hook "hook-distutils.py"...
  17741 INFO: Loading module hook "hook-encodings.py"...
  17880 INFO: Loading module hook "hook-kivy.py"...
  [INFO   ] [Factory     ] 194 symbols loaded
  17918 INFO: [Factory     ] 194 symbols loaded
  [INFO   ] [Logger      ] Record log in C:\Users\jakub\.kivy\logs\kivy_18-05-11_33.txt
  [INFO   ] [Kivy        ] v1.10.0
  [INFO   ] [Python      ] v3.6.5 (v3.6.5:f59c0932b4, Mar 28 2018, 16:07:46) [MSC v.1900 32 bit (Intel)]
  [INFO   ] [Image       ] Providers: img_tex, img_dds, img_sdl2, img_pil, img_gif (img_ffpyplayer ignored)
  [INFO   ] [Logger      ] Record log in C:\Users\jakub\.kivy\logs\kivy_18-05-11_34.txt
  [INFO   ] [Kivy        ] v1.10.0
  [INFO   ] [Python      ] v3.6.5 (v3.6.5:f59c0932b4, Mar 28 2018, 16:07:46) [MSC v.1900 32 bit (Intel)]
  [INFO   ] [Audio       ] Providers: audio_sdl2 (audio_ffpyplayer ignored)
  [INFO   ] [Image       ] Providers: img_tex, img_dds, img_sdl2, img_pil, img_gif (img_ffpyplayer ignored)
  [CRITICAL] [Camera      ] Unable to find any valuable Camera provider.
  opencv - ModuleNotFoundError: No module named 'cv2'
    File "c:\program files (x86)\python36-32\lib\site-packages\kivy\core\__init__.py", line 59, in core_select_lib
      fromlist=[modulename], level=0)
    File "c:\program files (x86)\python36-32\lib\site-packages\kivy\core\camera\camera_opencv.py", line 45, in &lt;module&gt;
      import cv2
  
  [INFO   ] [Clipboard   ] Provider: winctypes
  [INFO   ] [Factory     ] 194 symbols loaded
  [INFO   ] [OSC         ] using &lt;thread&gt; for socket
  [INFO   ] [Window      ] Provider: sdl2
  [INFO   ] [GL          ] Using the "OpenGL" graphics system
  [INFO   ] [GL          ] GLEW initialization succeeded
  [INFO   ] [GL          ] Backend used &lt;glew&gt;
  [INFO   ] [GL          ] OpenGL version &lt;b'4.0.0 - Build 10.18.10.4885'&gt;
  [INFO   ] [GL          ] OpenGL vendor &lt;b'Intel'&gt;
  [INFO   ] [GL          ] OpenGL renderer &lt;b'Intel(R) HD Graphics 4000'&gt;
  [INFO   ] [GL          ] OpenGL parsed version: 4, 0
  [INFO   ] [GL          ] Shading version &lt;b'4.00 - Build 10.18.10.4885'&gt;
  [INFO   ] [GL          ] Texture max size &lt;16384&gt;
  [INFO   ] [GL          ] Texture max units &lt;16&gt;
  [INFO   ] [Window      ] auto add sdl2 input provider
  [INFO   ] [Window      ] virtual keyboard not allowed, single mode, not docked
  [CRITICAL] [Spelling    ] Unable to find any valuable Spelling provider.
  enchant - ModuleNotFoundError: No module named 'enchant'
    File "c:\program files (x86)\python36-32\lib\site-packages\kivy\core\__init__.py", line 59, in core_select_lib
      fromlist=[modulename], level=0)
    File "c:\program files (x86)\python36-32\lib\site-packages\kivy\core\spelling\spelling_enchant.py", line 6, in &lt;module&gt;
      import enchant
  
  [INFO   ] [Text        ] Provider: sdl2
  [INFO   ] [Video       ] Provider: null(['video_ffmpeg', 'video_ffpyplayer'] ignored)
  28451 INFO: Excluding import 'tkinter'
  28468 INFO: Excluding import '_tkinter'
  28487 INFO: Excluding import 'twisted'
  28502 INFO:   Removing import of twisted.internet.error from module kivy.support
  28502 INFO:   Removing import of twisted.internet from module kivy.support
  28503 INFO:   Removing import of twisted.internet.reactor from module kivy.support
  28503 INFO:   Removing import of twisted from module kivy.support
  28503 INFO:   Removing import of twisted.internet._threadedselect from module kivy.support
  28509 INFO: Loading module hook "hook-kivymd.py"...
  28803 INFO: Loading module hook "hook-lib2to3.py"...
  28827 INFO: Loading module hook "hook-numpy.core.py"...
  29506 INFO: Loading module hook "hook-PIL.Image.py"...
  30153 INFO: Loading module hook "hook-PIL.py"...
  30160 INFO: Excluding import 'tkinter'
  30166 INFO:   Removing import of tkinter from module PIL.ImageTk
  30169 INFO: Excluding import 'PyQt5'
  30175 INFO: Excluding import 'PySide'
  30179 INFO:   Removing import of PySide.QtGui from module PIL.ImageQt
  30180 INFO:   Removing import of PySide.QtCore from module PIL.ImageQt
  30182 INFO: Import to be excluded not found: 'FixTk'
  30182 INFO: Excluding import 'PyQt4'
  30190 INFO: Loading module hook "hook-PIL.SpiderImagePlugin.py"...
  30198 INFO: Excluding import 'tkinter'
  30202 INFO: Import to be excluded not found: 'FixTk'
  30202 INFO: Loading module hook "hook-pkg_resources.py"...
  31050 INFO: Processing pre-safe import module hook   win32com
  31213 INFO: Loading module hook "hook-pydoc.py"...
  31222 INFO: Loading module hook "hook-pygments.py"...
  33573 INFO: Loading module hook "hook-PySide.py"...
  33574 INFO: Loading module hook "hook-PySide.QtCore.py"...
  33697 INFO: Loading module hook "hook-PySide.QtGui.py"...
  34265 INFO: Loading module hook "hook-pythoncom.py"...
  34633 INFO: Loading module hook "hook-pywintypes.py"...
  35002 INFO: Loading module hook "hook-setuptools.py"...
  35053 INFO: Loading module hook "hook-sysconfig.py"...
  35056 INFO: Loading module hook "hook-win32com.py"...
  35836 INFO: Loading module hook "hook-xml.dom.domreg.py"...
  35838 INFO: Loading module hook "hook-xml.etree.cElementTree.py"...
  35839 INFO: Loading module hook "hook-xml.py"...
  35844 INFO: Loading module hook "hook-_tkinter.py"...
  35951 WARNING: lib not found: api-ms-win-crt-runtime-l1-1-0.dll dependency of c:\program files (x86)\python36-32\DLLs\_tkinter.pyd
  36045 WARNING: lib not found: api-ms-win-crt-stdio-l1-1-0.dll dependency of c:\program files (x86)\python36-32\DLLs\_tkinter.pyd
  36235 INFO: checking Tree
  36289 INFO: checking Tree
  36309 INFO: Loading module hook "hook-docutils.py"...
  38732 INFO: Looking for ctypes DLLs
  38890 INFO: Analyzing run-time hooks ...
  38909 INFO: Including run-time hook 'pyi_rth_multiprocessing.py'
  38917 INFO: Including run-time hook 'pyi_rth_twisted.py'
  38919 INFO: Including run-time hook 'pyi_rth_pkgres.py'
  38921 INFO: Including run-time hook 'pyi_rth_win32comgenpy.py'
  38924 INFO: Including run-time hook 'pyi_rth__tkinter.py'
  38929 INFO: Including run-time hook 'pyi_rth_kivy.py'
  38932 INFO: Including run-time hook 'pyi_rth_gstreamer.py'
  38974 INFO: Looking for dynamic libraries
  
  79855 INFO: Looking for eggs
  79855 INFO: Using Python library c:\program files (x86)\python36-32\python36.dll
  79857 INFO: Found binding redirects:
  []
  79889 INFO: Warnings written to C:\Users\jakub\Desktop\python\Datelbot\build\datelbot.exe\warndatelbot.exe.txt
  80369 INFO: Graph cross-reference written to C:\Users\jakub\Desktop\python\Datelbot\build\datelbot.exe\xref-datelbot.exe.html
  80589 INFO: Appending 'binaries' from .spec
  80606 INFO: checking PYZ
  80621 INFO: Building because toc changed
  80622 INFO: Building PYZ (ZlibArchive) C:\Users\jakub\Desktop\python\Datelbot\build\datelbot.exe\out00-PYZ.pyz
  86657 INFO: Building PYZ (ZlibArchive) C:\Users\jakub\Desktop\python\Datelbot\build\datelbot.exe\out00-PYZ.pyz completed successfully.
  86768 INFO: checking PKG
  86785 INFO: Building because toc changed
  86786 INFO: Building PKG (CArchive) out00-PKG.pkg
  98225 INFO: Building PKG (CArchive) out00-PKG.pkg completed successfully.
  98317 INFO: Bootloader c:\program files (x86)\python36-32\lib\site-packages\PyInstaller\bootloader\Windows-32bit\run.exe
  98318 INFO: checking EXE
  98336 INFO: Building because toc changed
  98337 INFO: Building EXE from out00-EXE.toc
  98457 INFO: SRCPATH [('img\\icon.ico', None)]
  98457 INFO: Updating icons from ['img\\icon.ico'] to C:\Users\jakub\AppData\Local\Temp\tmpx5kpyaoj
  98460 INFO: Writing RT_GROUP_ICON 0 resource with 20 bytes
  98463 INFO: Writing RT_ICON 1 resource with 43720 bytes
  98634 INFO: Appending archive to EXE C:\Users\jakub\Desktop\python\Datelbot\dist\Datelbot.exe
  98878 INFO: Building EXE from out00-EXE.toc completed successfully.
  </code></pre>
  
  <p><em>Note: The PyInstaller output also contains lot of warnings about dependencies (<code>.dll</code>, <code>.pyd</code>) such as described <a href="https://stackoverflow.com/questions/39687975/pyinstaller-lib-not-found">here</a></em></p>
  
  <p>I am using Windows 10 Insider Preview build, Python 3.6.5 and I have installed all the Kivy deps.</p>