title: How to play sound using Python
body: <p>I want a Python script that I can run in the background on my Windows machine which plays a sound file.</p>
  <p>I have two different scripts which only work when I copy and paste the code into the Python interpreter. The sound will play successfully.</p>
  <p>If instead I go to <code>cmd</code> and type <code>python run.py</code>, the script will run with the same standard out, but there will be no sound played.</p>
  <pre><code># can only hear sound when this code is run in interpreter
  from pygame import mixer
  mixer.init()
  mixer.music.load(&quot;C:\\Sound.mp3&quot;)
  mixer.music.play()
  </code></pre>
  <pre><code># can only hear sound when this code is run in interpreter
  import winsound
  winsound.PlaySound(&quot;C:\\Sound.wav&quot;, winsound.SND_ASYNC)
  </code></pre>
  <p>How to resolve this?</p>