4

Been using the safe and easy confines of PyCharm for a bit now, but I'm trying to get more familiar with using a text editor and the terminal together, so I've forced myself to start using iPython Notebook and Emacs. Aaaaand I have some really dumb questions.

  • after firing up ipython notebook from terminal with the command 'ipython notebook', it pops up on my browser and lets me code. but can i not use terminal while it's connected to ipython notebook server?

  • after writing my code in ipython notebook, i'm left with a something.ipynb file. How do I run this file from terminal? If it was a .py file, i know i could execute it by tying python something.py from the command line; but it doesn't work if i type python something.ipynb in the command line. And of course, I assume I hit Control-C to quit out of the running server in terminal first? or do I run the command without quitting that? Or am i doomed to test it in iPython and then copy and paste it to a different txt editor like Emacs and save it in a .py file to run it?

  • what good is the .ipynb file if i can't run it in terminal or outside the iPython Notebook browser? Could I get my code in a .py from iPython Notebook if I wanted to? (i assume I'll be able to easily run it in terminal by tying something.py then)

thanks in advance. I'm still very much trying to figure out how to use this thing and there aren't many answers out there for questions this elementary.

SpicyClubSauce
  • 4,076
  • 13
  • 37
  • 62
  • open another terminal if you want to code there? `file>download as... ` to save as .py. – monkut May 13 '15 at 06:22
  • what's the use of saving something as a .ipynb file? – SpicyClubSauce May 13 '15 at 06:23
  • An .ipynb file is useful because you can share or publish it, either directly or by rendering it to some static format like html first. – 1.618 May 13 '15 at 06:44
  • 1
    I use Ipython Notebook as a notebook. Most often I use it as "scratch-paper" when I'm playing around with code. I have and I see many people using it for display/briefs. Rather than giving a technical brief on powerpoint use notebook. Have all your code, graphs, LaTeX ready and give a brief with running code. Here is a great example of how it can be used http://www.nature.com/news/ipython-interactive-demo-7.21492 – Scott May 13 '15 at 06:47
  • 1
    I'm voting to close this question as off-topic because this isn't about programming it's about how to use a text editor. – GreenAsJade May 13 '15 at 07:45
  • It's better to pose multiple questions separately here. And then your question title can actually say what the question is. It's fine to include in the title that it is a *first-time user* question, but it is even more important to say **what** the question is in the title. This question cannot be retitled to help others because this is a list of questions, not one question. – Drew May 13 '15 at 13:35
  • To be fair, iPython is not a text editor: it's more like RStudio. Almost a lightweight IDE -- that's stretching it. It allows you to write in Markdown and in Python (and now in R) and to execute code in the code blocks. It's a great way to code, to document your work (that may not necessarily need or want to go in to comments) and to share all that with others. As [Scott](http://stackoverflow.com/users/4663466/scott) notes, you can export code, HTML, or even a Reveal.js presentation. (And probably a half dozen other outputs that I haven't tried yet.) – John Laudun May 13 '15 at 22:15

2 Answers2

3
  • Yes, you can not use the same terminal. Solutions: open another terminal or run ipython notebook inside screen. If you use Windows you might want to take a look into this question
  • Notebook documents (ipynb files) can be converted to a range of static formats including LaTeX, HTML, PDF and Python. Read more about converting notebooks in manual
  • Notebooks are great, because you can show other people your interactive sessions accompanied with text, which may have rich formatting. And if someone can run notebook server he can easily reproduce your computations and maybe modify them. Check out awesome notebook on traveling salesperson problem by Peter Norvig as an example of what you can do with ipynb. Or this notebook. More examples are available here
Community
  • 1
  • 1
Konstantin
  • 24,271
  • 5
  • 48
  • 65
1
  • You can run your IPython notebook process in background.

On Unix platforms you can perform that with (note the leading &):

ipython notebook &

Or after a "normal" run, hit [Control+z] and run the bg command (some lecture).

  • you can convert .ipynb file into .py file using nbconvert

with Ipython notebook 2.x (some lecture):

ipython nbconvert --to python mynotebook.ipynb

with Ipython notebook 3.x (some lecture):

  ipython nbconvert --to script mynotebook.ipynb
  • .ipynb contains your script AND results AND formatted text. You can compare it to a literate script (but using "machine programming language").
alain
  • 657
  • 6
  • 8