title: Errors when trying to change the font in python and render text using Latex
body: <p>I am trying to change the font that python uses for graphing. I have greek letters and other symbols that I need to use so I have been trying to use their latex form. I would like to save the figure in pdf form. I am using the Spyder environment to program in; my Spyder and python are from anaconda. </p>
  
  <p>I am trying to execute the program specified by <a href="http://matplotlib.org/1.3.1/users/usetex.html" rel="nofollow noreferrer">http://matplotlib.org/1.3.1/users/usetex.html</a> -- I have followed the instructions and made sure that I have the three prerequisites for this to work and that they are in my path -- "a working LaTeX installation, dvipng (which may be included with your LaTeX installation), and Ghostscript (GPL Ghostscript 8.60 or later is recommended). The executables for these external dependencies must all be located on your PATH."</p>
  
  <pre><code>import numpy as np
  import matplotlib.pyplot as plt
  
  
  # Example data
  t = np.arange(0.0, 1.0 + 0.01, 0.01)
  s = np.cos(4 * np.pi * t) + 2
  
  plt.rc('text', usetex=True)
  plt.rc('font', family='serif')
  plt.plot(t, s)
  
  plt.xlabel(r'\textbf{time} (s)')
  plt.ylabel(r'\textit{voltage} (mV)',fontsize=16)
  plt.title(r"\TeX\ is Number "
            r"$\displaystyle\sum_{n=1}^\infty\frac{-e^{i\pi}}{2^n}$!",
            fontsize=16, color='gray')
  # Make room for the ridiculously large title.
  plt.subplots_adjust(top=0.8)
  
  #plt.savefig('tex_demo')
  plt.show()
  </code></pre>
  
  <p>When I run this program with the second to last line of that program commented out, a graph shows up with the curve plotted, but nothing else - no axis labels or title or axis tick marks.</p>
  
  <p>And if I uncomment the line plt.savefig('tex_demo') or try plt.savefig('test_demo.pdf',format='pdf',bbox_inches='tight') I get the error:</p>
  
  <pre><code>In [3]: runfile('/Users/Emily/Documents/Research/Masters_Thesis/Examples/tex_demo.py', wdir='/Users/Emily/Documents/Research/Masters_Thesis/Examples')
  Traceback (most recent call last):
  
    File "&lt;ipython-input-3-9b7e3d9c6b78&gt;", line 1, in &lt;module&gt;
  
  ... lots of lines here
  
    File "/Users/Emily/anaconda/lib/python2.7/site-packages/matplotlib/dviread.py", line 876, in find_tex_file
      stderr=subprocess.PIPE)
  
    File "/Users/Emily/anaconda/lib/python2.7/subprocess.py", line 710, in __init__
      errread, errwrite)
  
    File "/Users/Emily/anaconda/lib/python2.7/subprocess.py", line 1335, in _execute_child
      raise child_exception
  
  OSError: [Errno 2] No such file or directory
  </code></pre>
  
  <p>I have tried other variations as well -- </p>
  
  <pre><code>import pylab as pl
  import matplotlib as mp
  ...
  mp.rc('text', usetex=True)
  mp.rc('font', family='serif')
  ...
  </code></pre>
  
  <p>get the same results when pl.savefig('tex_demo') is commented (no axes) or uncommented (OS Error).</p>
  
  <p>I looked around to see if anyone else has had the same problem but often the errors associated with "OSError: [Errno 2] No such file or directory" python are not in the same context as I am. </p>
  
  <p>With this variation (<a href="https://stackoverflow.com/questions/17958485/matplotlib-not-using-latex-font-while-text-usetex-true">Matplotlib not using latex font while text.usetex==True</a>),</p>
  
  <pre><code>from matplotlib import rc
  import matplotlib.pylab as plt
  
  rc('font', **{'family': 'serif', 'serif': ['Computer Modern']})
  rc('text', usetex=True)
  
  x = plt.linspace(0,5)
  plt.plot(x,plt.sin(x))
  plt.ylabel(r"This is $\sin(x)$", size=20)
  plt.show()
  </code></pre>
  
  <p>I'll get the error (which is the error I started with but have gotten less frequently after I installed Ghostscript): </p>
  
  <pre><code>Traceback (most recent call last):
  
  ... lots of lines here.
  
    File "/Users/Emily/anaconda/lib/python2.7/site-packages/matplotlib/texmanager.py", line 670, in get_text_width_height_descent
      dvifile = self.make_dvi(tex, fontsize)
  
    File "/Users/Emily/anaconda/lib/python2.7/site-packages/matplotlib/texmanager.py", line 417, in make_dvi
      report))
  
  RuntimeError: LaTeX was not able to process the following string:
  'lp'
  Here is the full report generated by LaTeX: 
  </code></pre>
  
  <p>with this error, I wasn't sure how to implement the suggestions of <a href="https://stackoverflow.com/questions/6082126/tex-in-matplotlib-on-mac-os-x-and-tex-live">TeX in matplotlib on Mac OS X and TeX Live</a> and <a href="https://www.pythonanywhere.com/forums/topic/228/" rel="nofollow noreferrer">https://www.pythonanywhere.com/forums/topic/228/</a></p>
  
  <p>Overall, I would just like to change the font of python while using greek letters or latex characters and save that figure in pdf form. Can anyone spot my error or point me in the right direction to fix my errors?</p>