Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to develop with ipython notebook

I am new to IPython Notebook. I am using the Anaconda distribution on CrunchBang (Waldorf). My development cycle is as follows:

1. Open Spyder.
2. Open the .py file if not already loaded
3. Start IPython Notebook
4. Open the specific notebook from the main IPython screen
5. Select Cell/Run All
6. Note errors. If none goto step 11.
7. Save and close the notebook
8. Shutdown the notebook from main IPython screen
9. Correct errors in Spyder and save
10. go to step 4
11. Move on to the next part of the project and start the process over.

Is there a better approach for a noob? This really gets monotonous although I am learning quite a bit.

Thanks in advance

like image 314
Ron Avatar asked Feb 12 '14 03:02

Ron


2 Answers

Forget Spyder for the time being just use the IPython notebook. 1, write code in notebook 2. test it 3. when done if needed make a py file...

You really will only need Spyder later for starting out it just complicates things for no gain

like image 124
dartdog Avatar answered Sep 20 '22 18:09

dartdog


Use Spyder and .py files for writing big functions, classes, modules, tests, etc.

Use IPython notebooks for interactive work where you want to keep the output together with the code (e.g. data processing and analysis, demos, etc.).


To add to Ian's answer, another useful tool is the autoreload extension, which reloads modules automatically when they are changed.

To use, type into your IPython console or notebook:

%load_ext autoreload
%autoreload 2

For example:

enter image description here

This way you can work on a Python file and an IPython notebook at the same time, without having to reload the Python file after each change.

like image 22
ostrokach Avatar answered Sep 21 '22 18:09

ostrokach