title: How can I include assets of a dash app into an exe file created with pyinstaller --onefile?
body: <p>I am trying to package a dash app into a single pyinstaller .exe and am running into some trouble including the assets folder.</p>
  
  <p>Here's what I have done so far:</p>
  
  <pre><code># get temp working directory
      import sys
      import os
      def resource_path(relative_path):
  
  # get absolute path to resource
      try:
          # PyInstaller creates a temp folder and stores path in _MEIPASS
          base_path = sys._MEIPASS
      except Exception:
          base_path = os.path.abspath(".")
  
      return os.path.join(base_path, relative_path)
  
  print(resource_path("assets"))
  </code></pre>
  
  <p>This gives me a the path to the current working directory/assets. It works in anaconda environment as well as in the .exe, giving me the right path in the console. </p>
  
  <p>But the next part is where I run into trouble:</p>
  
  <pre><code># create app
  app = dash.Dash(__name__, assets_url_path=resource_path("assets"))
  </code></pre>
  
  <p>Normally, <code>assets_url_path=</code> can be used to set the asset path for dash apps. Specifically, I have my css file for formatting stored here, but it should be the same process for any asset. For some reason, however, the assets don't get used in the pyinstaller version of the app, despite <code>print(resource_path("assets"))</code> showing the correct path in the system's <code>Temp</code> directory. I can even navigate there and see my <code>styles.css</code>, but somehow dash doesn't pick it up.</p>
  
  <p>What confuses me is that the exact same code works perfectly fine in my anaconda environment. The only difference should be that the temporary path is my home directory instead. What am I missing here?</p>