title: TclError: no display name and no $DISPLAY environment variable on EC2
body: <p>I'd like to use iPython on an Amazon EC2 (Linux AMI). I've installed Anaconda and started iPython to test out some scripts I've already created. Right now I am only interested in running it in Terminal (<strong>not</strong> as Notebook).</p>
  
  <p>At the beginning of my code I always do:</p>
  
  <pre><code>import json
  import numpy as np
  import pandas as pd
  from pandas import Series, DataFrame
  </code></pre>
  
  <p>However, I tried CTRL + C from my text editor and then using %paste in Terminal I get the error:</p>
  
  <pre><code>TclError: no display name and no $DISPLAY environment variable
  </code></pre>
  
  <p>If I try to ssh -X name@host as per this suggestion <a href="https://stackoverflow.com/questions/19309085/no-display-name-and-no-display-environment-variable-using-tkinter-through-ssh">No display name and no $DISPLAY environment variable using tkinter through ssh</a>, I get:</p>
  
  <pre><code>/opt/X11/bin/xauth:  file /Users/adrianp/.Xauthority does not exist
  Warning: untrusted X11 forwarding setup failed: xauth key data not generated
  X11 forwarding request failed on channel 0
  </code></pre>
  
  <p>To fix that issue I tried <a href="https://superuser.com/questions/249045/x11-forwarding-from-amazon-ec2-ami">https://superuser.com/questions/249045/x11-forwarding-from-amazon-ec2-ami</a> but still got a warning:</p>
  
  <pre><code> Warning: untrusted X11 forwarding setup failed: xauth key data not generated
  </code></pre>
  
  <p>And the same error:</p>
  
  <pre><code>TclError: no display name and no $DISPLAY environment variable
  </code></pre>
  
  <p>Per this suggestion <a href="https://stackoverflow.com/questions/2801882/generating-a-png-with-matplotlib-when-display-is-undefined">Generating a PNG with matplotlib when DISPLAY is undefined</a> (which seems irrelevant but I've tried everything) I did:</p>
  
  <pre><code>import matplotlib
  matplotlib.use('Agg')
  </code></pre>
  
  <p>before importing anything else and still get the same error.</p>
  
  <p>Any ideas on how to solve this problem? I'd really like to use the paste magic function to input functions/etc.</p>