title: How to use Cython to compile Python 3 into C
body: <p>I'm trying to convert a Python 3 script into C and then compile that C file into an executable.</p>
  
  <p>I have this simple python script:</p>
  
  <pre><code>def greet(name = ""):
    print("Hello {0}".format(name if len(name) &gt; 0 else "World"))
  
  greet("Mango")
  </code></pre>
  
  <p>I've converted this script into C using:<br/></p>
  
  <pre><code>cython greet.py -o greet.c
  </code></pre>
  
  <p>Then I've compiled the C file using:</p>
  
  <pre><code>cc greet.c -o greet
  </code></pre>
  
  <p>After I entered the last command I got the error:</p>
  
  <blockquote>
    <p>fatal error: Python.h: No such file or directory compilation terminated.</p>
  </blockquote>
  
  <p>After I got the error I went back and realised that I was using Python3 and that I had forgot the "3" after "cython".<br />
  So re-compiled the python script using:</p>
  
  <pre><code>cython3 greet.py -o greet.c
  </code></pre>
  
  <p>Then attempted to re-compile the C file using:</p>
  
  <pre><code>cc greet.c -o greet
  </code></pre>
  
  <p>Again this failed and threw the same error so I went searching on SO and Google and found these questions:</p>
  
  <ul>
  <li><a href="https://stackoverflow.com/questions/21530577/fatal-error-python-h-no-such-file-or-directory">fatal error: Python.h: No such file or directory</a></li>
  <li><a href="https://stackoverflow.com/questions/8282231/ubuntu-i-have-python-but-gcc-cant-find-python-h">I have Python on my Ubuntu system, but gcc can&#39;t find Python.h</a></li>
  <li><a href="https://askubuntu.com/questions/526708/fatal-error-python-h-no-file-or-directory">https://askubuntu.com/questions/526708/fatal-error-python-h-no-file-or-directory</a></li>
  </ul>
  
  <p>None of these answers in these questions work.</p>
  
  <p>I've made sure that I have installed cython all of the correct dependencies using <code>apt-get install</code> and <code>pip install</code> sadly thought it still does not seem to work.</p>