title: How to set a dictionary based off of subprocess.check_output
body: <p>This is a confusing question, however I will try to make it as clear as possible.
  Currently when I build my app, if I run it via the .py file it works perfectly. However, once I compile it some parts of my app aren't functioning, specifically this code here.</p>
  <pre><code>def ffprobe_run():
  global output
  global acodec_choices
  run = subprocess.check_output(&quot;ffprobe &quot; + videoinputquoted + &quot; &quot; + ffprobecommand, universal_newlines=True)
  print(run)
  if run[-2] == '3':
      acodec_choices = {&quot;One&quot;: &quot;1&quot;,
                        &quot;Two&quot;: &quot;2&quot;,
                        &quot;Three&quot;: &quot;3&quot;}
  elif run[-2] == '2':
      acodec_choices = {&quot;One&quot;: &quot;1&quot;,
                        &quot;Two&quot;: &quot;2&quot;,}
  elif run[-2] == '1':
      acodec_choices = {&quot;One&quot;: &quot;1&quot;,}
  print(acodec_choices.values())
  </code></pre>
  <p>I am able to get the results I want with this command. Currently that's using FFPROBE to check for the amount of audio tracks there is in a file. It returns values like so</p>
  <pre><code>1
  2
  3
  </code></pre>
  <p>If there is 3 tracks. Or</p>
  <pre><code>1 
  2
  </code></pre>
  <p>If it's two tracks. I use the command[-2]
  which will give me the result of '2'</p>
  <p>So I'm taking that result and defining a dictionary to automatically populate/change an OptionMenu</p>
  <p>It defines this in my main app</p>
  <pre><code> # Audio Stream Selection
      acodec_stream = StringVar(audio_window)
      if ffprobeinfo[-2] == '1':
          acodec_stream_choices = {'Track 1': &quot;-map 0:a:0&quot;}
      elif ffprobeinfo[-2] == '2':
          acodec_stream_choices = {'Track 1': &quot;-map 0:a:0&quot;,
                                   'Track 2': &quot;-map 0:a:1&quot;}
      elif ffprobeinfo[-2] == '3':
          acodec_stream_choices = {'Track 1': &quot;-map 0:a:0&quot;,
                                   'Track 2': &quot;-map 0:a:1&quot;,
                                   'Track 3': &quot;-map 0:a:2&quot;}
      elif ffprobeinfo[-2] == '4':
          acodec_stream_choices = {'Track 1': &quot;-map 0:a:0&quot;,
                                   'Track 2': &quot;-map 0:a:1&quot;,
                                   'Track 3': &quot;-map 0:a:2&quot;,
                                   'Track 4': &quot;-map 0:a:3&quot;}
      elif ffprobeinfo[-2] == '5':
          acodec_stream_choices = {'Track 1': &quot;-map 0:a:0&quot;,
                                   'Track 2': &quot;-map 0:a:1&quot;,
                                   'Track 3': &quot;-map 0:a:2&quot;,
                                   'Track 4': &quot;-map 0:a:3&quot;,
                                   'Track 5': &quot;-map 0:a:4&quot;}
      elif ffprobeinfo[-2] == '6':
          acodec_stream_choices = {'Track 1': &quot;-map 0:a:0&quot;,
                                   'Track 2': &quot;-map 0:a:1&quot;,
                                   'Track 3': &quot;-map 0:a:2&quot;,
                                   'Track 4': &quot;-map 0:a:3&quot;,
                                   'Track 5': &quot;-map 0:a:4&quot;,
                                   'Track 6': &quot;-map 0:a:5&quot;}
      elif ffprobeinfo[-2] == '7':
          acodec_stream_choices = {'Track 1': &quot;-map 0:a:0&quot;,
                                   'Track 2': &quot;-map 0:a:1&quot;,
                                   'Track 3': &quot;-map 0:a:2&quot;,
                                   'Track 4': &quot;-map 0:a:3&quot;,
                                   'Track 5': &quot;-map 0:a:4&quot;,
                                   'Track 6': &quot;-map 0:a:5&quot;,
                                   'Track 7': &quot;-map 0:a:6&quot;}
      elif ffprobeinfo[-2] == '8':
          acodec_stream_choices = {'Track 1': &quot;-map 0:a:0&quot;,
                                   'Track 2': &quot;-map 0:a:1&quot;,
                                   'Track 3': &quot;-map 0:a:2&quot;,
                                   'Track 4': &quot;-map 0:a:3&quot;,
                                   'Track 5': &quot;-map 0:a:4&quot;,
                                   'Track 6': &quot;-map 0:a:5&quot;,
                                   'Track 7': &quot;-map 0:a:6&quot;,
                                   'Track 8': &quot;-map 0:a:7&quot;}
      elif ffprobeinfo[-2] == '9':
          acodec_stream_choices = {'Track 1': &quot;-map 0:a:0&quot;,
                                   'Track 2': &quot;-map 0:a:1&quot;,
                                   'Track 3': &quot;-map 0:a:2&quot;,
                                   'Track 4': &quot;-map 0:a:3&quot;,
                                   'Track 5': &quot;-map 0:a:4&quot;,
                                   'Track 6': &quot;-map 0:a:5&quot;,
                                   'Track 7': &quot;-map 0:a:6&quot;,
                                   'Track 8': &quot;-map 0:a:7&quot;,
                                   'Track 9': &quot;-map 0:a:8&quot;}
      elif ffprobeinfo[-2] == '10':
          acodec_stream_choices = {'Track 1': &quot;-map 0:a:0&quot;,
                                   'Track 2': &quot;-map 0:a:1&quot;,
                                   'Track 3': &quot;-map 0:a:2&quot;,
                                   'Track 4': &quot;-map 0:a:3&quot;,
                                   'Track 5': &quot;-map 0:a:4&quot;,
                                   'Track 6': &quot;-map 0:a:5&quot;,
                                   'Track 7': &quot;-map 0:a:6&quot;,
                                   'Track 8': &quot;-map 0:a:7&quot;,
                                   'Track 9': &quot;-map 0:a:8&quot;,
                                   'Track 10': &quot;-map 0:a:9&quot;}
      acodec_stream.set('Track 1')  # set the default option
      acodec_stream_label = Label(audio_window, text=&quot;Track :&quot;)
      acodec_stream_label.grid(row=0, column=0, columnspan=1, padx=5, pady=5)
      acodec_stream_menu = OptionMenu(audio_window, acodec_stream, *acodec_stream_choices.keys())
      acodec_stream_menu.grid(row=1, column=0, columnspan=1, padx=5, pady=5)
  </code></pre>
  <p>This is all working great, If I am running the app via the .py file. Once I compile it's missing the entire defined dictionary selection.</p>
  <p>This is what it's supposed to look like
  <a href="https://i.stack.imgur.com/pPSRD.png" rel="nofollow noreferrer">enter image description here</a></p>
  <p>However, this is what it looks like with the code above. <a href="https://i.stack.imgur.com/gJCfS.png" rel="nofollow noreferrer">enter image description here</a></p>
  <p>If I define the dictionary myself, it works fine. However, then I can't automatically input the correct amount of available audio tracks.</p>
  <p>I hope this isn't too much code. I'm very new at this.</p>
  <p>EDIT:</p>
  <p>If I compile via pyinstaller and remove the -w flag, the program runs correctly, shows the tracks.</p>
  <p>I'm assuming I'm not using subprocess/calling something correctly. The program I don't think is calling to FFPROBE when it doesn't have a console, vs calling it and getting the value when it has it's own console.</p>