title: Cannot import .py file to ipython notebook
body: <p>With apologies in advance for the "I can't get it to work" question: How should I load a <code>.py</code> file into ipython notebook? I want to convert python code to notebooks (first simple scripts and later scripts that include <code>nbconvert</code> directives <a href="http://ipython.org/ipython-doc/2/notebook/nbconvert.html#notebook-json-file-format" rel="nofollow">embedded as comments</a>-- see bottom of the linked file.)</p>
  
  <p>Perhaps I'm doing it wrong, but perhaps there's something wrong with my set-up. When I drag a <code>.py</code> file to the Notebook's file list, I get the message </p>
  
  <blockquote>
    <p>Invalid file type: Uploaded notebooks must be <code>.ipynb</code> files.</p>
  </blockquote>
  
  <p>I even tried changing the extension to <code>.ipynb</code> (keeping the python script unmodified); reasonably enough, I got an error:</p>
  
  <blockquote>
    <p>Error loading notebook: Bad request</p>
  </blockquote>
  
  <p>Any idea what's going wrong? </p>
  
  <p>System information: I'm on OS X (10.8, Mountain Lion), using Firefox 28.0 and  Anaconda 1.9.2 (x86_64), which supplies python 2.7.6 and ipython 2.0. Anaconda is not on the default PATH; I add it in a bash session from which I then launch notebook with <code>ipython notebook</code>, and I'm able to open and edit <code>.ipynb</code> files normally in the browser. </p>
  
  <p>But I do get some curious behavior: 
  <strong>When exporting from notebook</strong> as a <code>.py</code> file, I don't get the control comments documented <a href="http://ipython.org/ipython-doc/2/notebook/nbconvert.html#notebook-json-file-format" rel="nofollow">here</a> but a simpler format, without version number:</p>
  
  <pre><code># coding: utf-8
  
  # In[ ]:
  
  print "This is a slide"
  
  ## Top-level title 
  
  ### Second-level heading 
  
  #### Third-level heading
  
  # This is some `markdown` text. 
  # 
  # And some more here.
  </code></pre>
  
  <p>Any idea what's going on here?</p>
  
  <p>The same format is generated by <code>ipython nbconvert</code>. However, if I start the notebook server with <code>ipython notebook --script</code> (which exports the notebook as a python script every time it is saved), the result contains the <code>nbconvert</code> directives we need to convert back to a notebook!</p>