title: wkhtmltopdf Error "No such file or directory" (Django)
body: <p>I am trying to use wkhtmltopdf to create a PDF from HTML code. I have used xhtml2pdf and pisa but I have had problems with css styles. well, wkhtmltopdf is my last option. </p>
  
  <p>I have followed this steps.  <a href="https://github.com/incuna/django-wkhtmltopdf" rel="noreferrer">https://github.com/incuna/django-wkhtmltopdf</a></p>
  
  <pre><code>sudo aptitude install libfontconfig
  pip install django-wkhtmltopdf
  </code></pre>
  
  <p>and if I add 'wkhtmltopdf' to my INSTALLED_APPS it will recognize the wkhtmltopdf path. </p>
  
  <pre><code>INSTALLED_APPS = ["wkhtmltopdf"]
  </code></pre>
  
  <p>Well, when I try to generate a PDF generate an error. </p>
  
  <p>this is my code:</p>
  
  <pre><code>from wkhtmltopdf.views import PDFTemplateResponse 
  
   context = {
              'linkedin1':self.linkedin1,
              'twitter1':self.twitter1,
              'facebook1':self.facebook1,
              'current': get_current_base_url,
             }
  
  
      html_path = "app/folder/page1_1.html"
      response = PDFTemplateResponse(request=request,
                                     template=html_path,
                                     filename="hello.pdf",
                                     context= context,
                                     show_content_in_browser=False,
                                     cmd_options=settings.WKHTMLTOPDF_CMD_OPTIONS,
                                     )
  </code></pre>
  
  <p>In settings:</p>
  
  <pre><code>WKHTMLTOPDF_CMD_OPTIONS = {
  'quiet': True,
  }
  </code></pre>
  
  <p>My error:</p>
  
  <pre><code> File "/home/user/.virtualenvs/app/local/lib/python2.7/site-   packages/django/core/handlers/base.py", line 136, in get_response
  response = response.render()
   File "/home/user/.virtualenvs/app/local/lib/python2.7/site-packages/django/template/response.py", line 104, in render
  self._set_content(self.rendered_content)
  File "/home/user/.virtualenvs/app/local/lib/python2.7/site- packages/wkhtmltopdf/views.py", line 144, in rendered_content
  footer_filename=footer_filename)
  File "/home/user/.virtualenvs/app/local/lib/python2.7/site-packages/wkhtmltopdf/views.py", line 103, in convert_to_pdf
  return wkhtmltopdf(pages=[filename], **cmd_options)
  File "/home/user/.virtualenvs/app/local/lib/python2.7/site-packages/wkhtmltopdf/utils.py", line 92, in wkhtmltopdf
  return check_output(ck_args, **ck_kwargs)
  File "/usr/lib/python2.7/subprocess.py", line 537, in check_output
  process = Popen(stdout=PIPE, *popenargs, **kwargs)
  File "/usr/lib/python2.7/subprocess.py", line 679, in __init__
  errread, errwrite)
  File "/usr/lib/python2.7/subprocess.py", line 1259, in _execute_child
  raise child_exception
  OSError: [Errno 2] No such file or directory
  </code></pre>
  
  <p>I think it cant't find 'wkhtmltopdf'. </p>
  
  <p>My wkhtmltopdf install path is:</p>
  
  <pre><code>/home/user/.virtualenvs/app/local/lib/python2.7/site-packages/wkhtmltopdf/
  </code></pre>
  
  <p>well I add in settings:</p>
  
  <pre><code>WKHTMLTOPDF_CMD = '/home/user/.virtualenvs/app/local/lib/python2.7/site-packages/wkhtmltopdf/'
  </code></pre>
  
  <p>To find the wkhtmltopdf's and appers "path permission denied"</p>
  
  <p>What is wrong?, what is missing?, what is the problem?.</p>
  
  <p>I am using:
  Ububtu server 12.04/64 bits, 
  Django 1.4, 
  Pyrhon 2.7, </p>
  
  <p>Thanks for your answers.</p>
  
  <p><strong>EDIT 1:</strong> </p>
  
  <p>I fixed mi problem doing that following this tutorial </p>
  
  <p><a href="http://www.cristalab.com/tutoriales/crear-pdf-en-django-y-virtualenv-c110664l/" rel="noreferrer">http://www.cristalab.com/tutoriales/crear-pdf-en-django-y-virtualenv-c110664l/</a></p>
  
  <pre><code>apt-get build-dep libqt4-gui libqt4-network libqt4-webkit
  apt-get install openssl build-essential xorg git-core git-doc libssl-dev wkhtmltopdf 
  </code></pre>
  
  <p>in settings</p>
  
  <pre><code>WKHTMLTOPDF_CMD = "/usr/bin/wkhtmltopdf"
  </code></pre>
  
  <p>But appered new error:</p>
  
  <pre><code>File "/home/user/.virtualenvs/app/local/lib/python2.7/site- packages/django/template/response.py", line 104, in render
  self._set_content(self.rendered_content)
  File "/home/user/.virtualenvs/app/local/lib/python2.7/site-  packages/wkhtmltopdf/views.py", line 144, in rendered_content
  footer_filename=footer_filename)
  File "/home/user/.virtualenvs/app/local/lib/python2.7/site-packages/wkhtmltopdf/views.py", line 103, in convert_to_pdf
  return wkhtmltopdf(pages=[filename], **cmd_options)
  File "/home/user/.virtualenvs/app/local/lib/python2.7/site-packages/wkhtmltopdf/utils.py", line 92, in wkhtmltopdf
  return check_output(ck_args, **ck_kwargs)
  File "/usr/lib/python2.7/subprocess.py", line 544, in check_output
  raise CalledProcessError(retcode, cmd, output=output)
  CalledProcessError: Command '['/usr/bin/wkhtmltopdf', '--encoding', u'utf8', '--quiet', '/tmp/wkhtmltopdfE_THjv.html', '-']' returned non-zero exit status 
  </code></pre>
  
  <p><strong>Solved:</strong> </p>
  
  <p>----------- July 14 -----------</p>
  
  <p>0) Create a ~/tmp/ directory and change into it</p>
  
  <pre><code>cd ~
  mkdir tmp
  cd tmp
  </code></pre>
  
  <p>1) libwkhtmltox-0.11.0_rc1-amd64.tar.bz2 and wkhtmltopdf-0.11.0_rc1-static-amd64.tar.bz2  from  <a href="http://code.google.com/p/wkhtmltopdf/downloads/list" rel="noreferrer">http://code.google.com/p/wkhtmltopdf/downloads/list</a></p>
  
  <pre><code> wget https://wkhtmltopdf.googlecode.com/files/libwkhtmltox-0.11.0_rc1-amd64.tar.bz2
  
   wget https://wkhtmltopdf.googlecode.com/files/wkhtmltopdf-0.11.0_rc1-static-amd64.tar.bz2
  </code></pre>
  
  <p>2) Create subfolders and move the files into them:</p>
  
  <pre><code> mkdir libwkhtmltox
   mkdir wkhtmltopdf
  
   mv libwkhtmltox-0.11.0_rc1-amd64.tar.bz2 libwkhtmltox
   mv wkhtmltopdf-0.11.0_rc1-static-amd64.tar.bz2 wkhtmltopdf
  </code></pre>
  
  <p>3) go in folders previously created and unzip the files. </p>
  
  <pre><code> cd libwkhtmltox
   tar -xvjf libwkhtmltox-0.11.0_rc1-amd64.tar.bz2 
   cd ../wkhtmltopdf
   tar -xvjf wkhtmltopdf-0.11.0_rc1-static-amd64.tar.bz2 
  </code></pre>
  
  <p>4) access to ‘lib’. there we find a file named  ‘libwkhtmltox.so’, then move it </p>
  
  <pre><code>cd ../libwkhtmltox/lib/
  sudo cp libwkhtmltox.so /usr/local/lib/
  </code></pre>
  
  <p>5) access to include, there we find a folder named ‘wkhtmltox’, then move it</p>
  
  <pre><code>cd ../include/
  sudo cp -avr wkhtmltox/ /usr/local/include/
  </code></pre>
  
  <p>6) after unzip the files we find the file “wkhtmltopdf-amd64”, move it.</p>
  
  <pre><code>cd ../../wkhtmltopdf/
  sudo cp wkhtmltopdf-amd64 /usr/bin/
  </code></pre>
  
  <p>7) I was following this post. <a href="http://www.cristalab.com/tutoriales/crear-pdf-en-django-y-virtualenv-c110664l/" rel="noreferrer">http://www.cristalab.com/tutoriales/crear-pdf-en-django-y-virtualenv-c110664l/</a></p>
  
  <p>8) install </p>
  
  <pre><code>sudo aptitude install libfontconfig
  
  sudo apt-get build-dep libqt4-gui libqt4-network libqt4-webkit 
  
  sudo apt-get install openssl build-essential xorg git-core git-doc libssl-dev wkhtmltopdf
  </code></pre>
  
  <p>9) I was following this post, <a href="https://github.com/incuna/django-wkhtmltopdf" rel="noreferrer">https://github.com/incuna/django-wkhtmltopdf</a></p>
  
  <p>10) later install the application</p>
  
  <pre><code> pip install django-wkhtmltopdf
  </code></pre>