title: Convert SVG to PNG with Python on Windows
body: <p><strong>Question: Which reproducible process can enable Windows Python users to render a SVG image into PNG?</strong></p>
  <hr />
  <p>Many questions/answers (such as <a href="https://stackoverflow.com/questions/6589358/convert-svg-to-png-in-python">Convert SVG to PNG in Python</a> and <a href="https://stackoverflow.com/questions/2932408/server-side-svg-to-png-or-some-other-image-format-in-python">Server-side SVG to PNG (or some other image format) in python</a>, which are not duplicates for the reasons explained below) explain how to convert a SVG to PNG with Python.</p>
  <p>Unfortunately, <strong>none of them are ready-to-use for Python + Windows</strong>. After more than 20 minutes, and many different attempts, I'm still unable to do it.
  More details about failing attempts:</p>
  <ul>
  <li><p>Installing <code>cairo</code> on Windows is not straightforward, we have to use Gohlke's binaries <a href="https://stackoverflow.com/questions/57178579/intalling-pycairo-with-python-3-7-on-windows">Intalling pycairo with Python 3.7 on Windows</a> :</p>
  <pre><code>pip install pycairo-1.20.0-cp37-cp37m-win_amd64.whl
  </code></pre>
  </li>
  <li><p>Even once <code>cairo</code> is installed, <code>rsvg</code> (from main answers of <a href="https://stackoverflow.com/questions/2932408/server-side-svg-to-png-or-some-other-image-format-in-python">Server-side SVG to PNG (or some other image format) in python</a>, <a href="https://stackoverflow.com/questions/6589358/convert-svg-to-png-in-python">Convert SVG to PNG in Python</a>) is not available for Windows:</p>
  <pre><code>pip install rsvg   # or pyrsvg
  &gt; ERROR: No matching distribution found for pyrsvg
  </code></pre>
  </li>
  <li><p>Solutions with <code>svglib</code> or <code>reportlab</code> don't work out-of-the-box on Python3 + Windows:</p>
  <pre><code>from svglib.svglib import svg2rlg
  from reportlab.graphics import renderPDF, renderPM
  drawing = svg2rlg(&quot;a.svg&quot;)
  renderPM.drawToFile(drawing, &quot;file.png&quot;, fmt=&quot;PNG&quot;)
  </code></pre>
  <p>Indeed:</p>
  <pre><code>AttributeError: 'Image' object has no attribute 'fromstring'
  </code></pre>
  </li>
  </ul>
  <p>So a solution - specific for Windows - would be helpful.</p>