title: How to unrar files
body: <p>I am trying to unrar files uploaded by users in django web application. I have gone through different approaches but none of them are working for me.
  The below methods work fine in my local OS (Ubuntu 18.04), but n't working in the server.
  I am using Python 3.6.</p>
  <ol>
  <li><p><strong>import rarfile</strong> - here 'rarfile' is imported from python3.6/site-packages/rarfile. It is giving this error -</p>
  <p><code>bsdtar: Error opening archive: Failed to open '--'</code></p>
  <p>Following the steps suggested <a href="https://stackoverflow.com/questions/37737850/python-rarfile-package-fail-to-open-files">here</a>, I installed 'unrar'.</p>
  </li>
  <li><p><strong>from unrar import rarfile</strong> - here it's being imported from python3.6/site-packages/unrar/</p>
  <p>But this gave the error - <code>LookupError: Couldn't find path to unrar library.</code></p>
  <p>So to solve the issue, I followed the steps mentioned <a href="https://stackoverflow.com/a/55577032/8090336">here</a>, and created UnRaR
  executable, and also set the path in my environment. This works fine in local, but unable to understand how to do the same in 'production environment'.</p>
  </li>
  <li><p><strong>import patoolib</strong> - importing from patool</p>
  <p>I also tried implementing patool, which worked fine in local but not in production and I am getting this error - <code>patoolib.util.PatoolError: could not find an executable program to extract format rar; candidates are (rar,unrar,7z),</code></p>
  </li>
  </ol>
  <p>This has become a big blocker in my application, can anyone please explain how to solve the problem.</p>
  <p><strong>Code snippet for rarfile -</strong></p>
  <pre><code>import rarfile
  .....        
  rf = rarfile.RarFile(file_path)
  rf.extractall(extract_to_path)
  </code></pre>
  <p><strong>Code snippet for patool -</strong></p>
  <pre><code>import patoolib
  ...
  patoolib.extract_archive(file_path, outdir=extract_to_path)
  </code></pre>