title: Convert PDF to Image using Python
body: <p>I am trying to convert a pdf file to image file for this in my ubuntu server i have installed:</p>
  
  <ol>
  <li>python2.7</li>
  <li>poppler-utils</li>
  <li>pdf2image==1.12.1</li>
  </ol>
  
  <p><strong>My code:</strong></p>
  
  <pre><code>from pdf2image import convert_from_path, convert_from_bytes
  
  images = convert_from_path("/home/user/pdf_file.pdf")
  
  # OR
  
  with open("/home/user/pdf_file.pdf") as pdf:
      images = convert_from_bytes(pdf.read())
  </code></pre>
  
  <p><strong>OUTPUT</strong></p>
  
  <p><strong>When I am using the function "convert_from_path"</strong></p>
  
  <pre><code>Traceback (most recent call last):
    File "&lt;stdin&gt;", line 1, in &lt;module&gt;
    File "/usr/local/lib/python2.7/dist-packages/pdf2image/pdf2image.py", line 143, in convert_from_path
      thread_output_file = next(output_file)
  TypeError: ThreadSafeGenerator object is not an iterator
  </code></pre>
  
  <p><strong>When I am using the function "convert_from_bytes"</strong></p>
  
  <pre><code>Traceback (most recent call last):
    File "&lt;stdin&gt;", line 2, in &lt;module&gt;
    File "/usr/local/lib/python2.7/dist-packages/pdf2image/pdf2image.py", line 268, in convert_from_bytes
      paths_only=paths_only,
    File "/usr/local/lib/python2.7/dist-packages/pdf2image/pdf2image.py", line 143, in convert_from_path
      thread_output_file = next(output_file)
  TypeError: ThreadSafeGenerator object is not an iterator
  </code></pre>
  
  <p>I have reinstalled all my utilities then i am facing these problems.</p>