title: Pyplot's savefig on Windows: Permission Error
body: <p><em>I've found a few similar questions, but this is - to my knowledge - not a duplicate. The other once mostly deal with a folder without permission to write on</em></p>
  
  <p>On my Windows 7 machine, I am working with pyCharm and git for Windows. There is some Python script (under version control) which is supposed to create and save a figure:</p>
  
  <pre><code>plt.savefig('filename.pdf', bbox_inches="tight", pad_inches=0)
  </code></pre>
  
  <p>This works very nicely - but only once. After that, I get an <code>IOError</code>:</p>
  
  <pre><code>Traceback (most recent call last):
    - snip - 
      return pdf.print_pdf(*args, **kwargs)
    File "(...)\enthought\canopy\user\lib\site-packages\matplotlib\backends\backend_pdf.py", line 2333, in print_pdf
      file = PdfFile(filename)
    File "(...)\enthought\canopy\user\lib\site-packages\matplotlib\backends\backend_pdf.py", line 400, in __init__
      fh = open(filename, 'wb')
  IOError: [Errno 13] Permission denied: 'myfile.pdf'
  </code></pre>
  
  <p>The error somehow appears to be in the file. pyplot seems not to have the permission to write over the already existing file. If I delete the previously generated file, it works (once). </p>
  
  <p>Using the Git cmd, I can do <code>ls -al</code> and get</p>
  
  <pre><code>-rw-r--r-- 1 myusername 197121    12927 17:00 myfile.pdf
  </code></pre>
  
  <p>which all appears to be correct. I'm somewhat stuck here, and I usually does not have any problems with writing over existing images with matplotlib. What can I do?</p>