title: gnupg.GPG: Sorry, no terminal at all requested - can't get input
body: <p>I am trying to encrypt a file using Python GNUPG library and it doesnt work!</p>
  
  <p>Here is my code snippet:</p>
  
  <pre><code>import gnupg
  
  gpg=gnupg.GPG(homedir='/home/datadev/')
  recipients=['realname@email.com']
  f = open('/home/datadev/filename','rb')
  status = gpg.encrypt(f,recipients)
  </code></pre>
  
  <p><code>/home/datadev</code> is the folder where I have my <code>.asc</code> file and all <code>.pubring</code> files related to <code>gpg</code>.</p>
  
  <p>After reading the post <a href="https://stackoverflow.com/questions/19298171/python-gnupg-encrypt-no-errors-but-not-encrypting-data-or-files"><strong><em>gpg: Sorry, no terminal at all requested - can't get input</em></strong></a></p>
  
  <p>I tried out the following option:</p>
  
  <pre><code>gpg=gnupg.GPG(options='')
  </code></pre>
  
  <p>but the error is always "gpg: Sorry, no terminal at all requested - can't get input"</p>
  
  <p>It would be helpful if someone could advise me as to what is wrong.</p>