title: NSIS after PyInstaller Kivy app can't find database
body: <p>I successfully packaged my Kivy app for Windows using PyInstaller and my app.exe runs without any problems. (.spec: <a href="https://stackoverflow.com/questions/35253158/kivy-1-9-1-windows-package-spec-single-exe">Kivy 1.9.1 Windows package .spec single exe</a>)</p>
  <p>For easier distribution I want to package my file to a single standalone .exe. My .nsi file:</p>
  <pre><code>SilentInstall silent
  Section
  InitPluginsDir
  Setoutpath KanjiOrigin
  File /r &quot;dist\KanjiOrigin\*&quot;
  ExecWait &quot;dist\KanjiOrigin\KanjiOrigin.exe&quot;
  Setoutpath $TEMP
  SectionEnd
  </code></pre>
  <p>A .exe is build without error: <a href="http://pastebin.com/h91jzGgY" rel="nofollow noreferrer">http://pastebin.com/h91jzGgY</a></p>
  <p>However when running this .exe made by NSIS, the app runs until I need to connect to my internal database at <code>data\db\Kanji-story.db</code>, which is not found. (When opening the .exe, it is in there, so the database has been included).</p>
  <pre><code>sqlite3.OperationalError: unable to open database: data\db\Kanji-story.db
  </code></pre>
  <p>When I extract my .exe with 7zip and try to run the KanjiOrigin.exe from PyInstaller, I get the following error: <code>D:\path\KanjiOrigin\KanjiOrigin.exe is not a valid Win32 application</code>. (Not sure if this is relevant).</p>
  <h2>Edit 2</h2>
  <p>I don't know what changed, but when opening the NSIS .exe with 7zip now, it doesn't give an error extracting the PyInstaller .exe anymore.
  However when trying to run the extracted PyInstaller .exe, I get the following error:</p>
  <pre><code>PyInstaller Bootloader 3.x
  LOADER: executable is D:\path\KanjiOrigin\KanjiOrigin.exe
  LOADER: homepath is D:\path\KanjiOrigin
  LOADER: _MEIPASS2 is NULL
  LOADER: archivename is D:\path\KanjiOrigin\KanjiOrigin.exe
  LOADER: pyi_arch_check_cookie failed
  LOADER: archivename is D:\path\KanjiOrigin\KanjiOrigin.pkg
  LOADER: Cannot open archive: D:\path\KanjiOrigin\KanjiOrigin.pkg
  Cannot open self D:\path\KanjiOrigin\KanjiOrigin.exe or archive D:\path\KanjiOrigin\KanjiOrigin.pkg
  </code></pre>
  <p>Also the included database doesn't seem to be corrupted, because after extraction I can successfully open it with sqlitebrowser (<a href="http://sqlitebrowser.org/" rel="nofollow noreferrer">http://sqlitebrowser.org/</a>).</p>
  <p>What do I do wrong? Is it <code>Setoutpath $TEMP</code>?</p>
  <h2>Edit:</h2>
  <p>If I manually include the database with the same folder structure (<code>data\db\Kanji-story.db</code>) outside the NSIS created .exe, it can find the database? Why can it find an external database, but not the internal one included in the NSIS .exe?</p>