7

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

Bill the Lizard
407k213 gold badges579 silver badges892 bronze badges
asked Feb 12, 2014 at 3:43

3 Answers 3

7

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

answered Feb 12, 2014 at 4:23
Sign up to request clarification or add additional context in comments.

4 Comments

Dartdog, Thanks for the advice. I was using Spyder to keep the clutter out of the notebook. But I think you're right. It just becomes too confusing jumping back and forth. With Ian's input above I'll retry the notebook only approach.
Dartdog, I was just thinking that part of the reason I was using separate files is the issue of location of functions in the notebook. Do you place all your functions at the beginning of the notebook or does it matter?
You can dev with your functions as you please and arrange them later. Just do what feels right. Eventually you move all imports to the front followed by functions. But sometimes as you are going along you may do a function and call it in a cell for testing nothing stops you from re arranging later
Thank you for the advice and direction. I really appreciate guidance from knowledgeable people.
7

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.

answered Mar 3, 2015 at 16:56

3 Comments

Does this actually work for you in IPython notebooks too? I only found this to work on the console before.
@MarkHorvath It works for me (added a screenshot). But I think you have to load autoreload before the other modules for it to work.
Great stuff! I had bad experience in earlier versions in IPython notebook (not sure if I made a mistake or it really didn't work). Confirmed, I does work now!
2

In addition to @dartdog's answer about developing directly in the notebook, if you must edit .py files used by the notebook then note the reload function which allows you to re-import already imported modules without having to shutdown and reopen the notebook.

answered Feb 12, 2014 at 7:45

1 Comment

Thanks for the advice. For some reason (noob?) I thought that only worked for IPython and not the notebook. Very lazy of me.

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.