title: Encoding issue with python3 and click package
body: <p>When the lib <a href="http://click.pocoo.org/" rel="noreferrer"><code>click</code></a> detects that the runtime is python3 but the encoding is ASCII then it ends the python program  abruptly:</p>
  
  <pre><code>RuntimeError: Click will abort further execution because Python 3 was configured to use ASCII as encoding for the environment. Either switch to Python 2 or consult http://click.pocoo.org/python3/ for mitigation steps.
  </code></pre>
  
  <p>I found the cause of this issue in my case, when I connect to my Linux host from my Mac, the Terminal.app set the SSH session locale to my Mac locale (es_ES.UTF-8) However my Linux host hasn't installed such locale (only en_US.utf-8).</p>
  
  <p>I applied an initial workaround to fix it (<em>but It had many issues, see accepted answer</em>):</p>
  
  
  
  <pre class="lang-python prettyprint-override"><code>import locale, codecs
  # locale.getpreferredencoding() == 'ANSI_X3.4-1968'
  if codecs.lookup(locale.getpreferredencoding()).name == 'ascii':
      os.environ['LANG'] = 'en_US.utf-8'
  </code></pre>
  
  <p><strong>EDIT: For a better patch see my accepted answer.</strong></p>
  
  <p>All my linux hosts have installed 'en_US.utf-8' as locale (Fedora uses it as default).</p>
  
  <p>My question is: <strong>Is there a better (more robust) way to choose/force the locale in a python3 script ?</strong> For instance, setting one of the available locales in the system.</p>
  
  <p>Maybe there is a different approach to fix this issue but I didn't find it.</p>