Tag Archives: jupyter

Jupyter Notebook Debugging

Debugging is an important concept. The concept of debugging is trying to figure out what is wrong with your code or just trying to understand the code. There are many times where I will come to unfamiliar code and I will need to step through it in a debugger to grasp how it works. Most Python IDEs have good debuggers built into them. I personally like Wing IDE for instance. Others like PyCharm or PyDev. But what if you want to debug the code in your Jupyter Notebook? How does that work?

In this chapter we will look at a couple of different methods of debugging a Notebook. The first one is by using Python’s own pdb module. Continue reading Jupyter Notebook Debugging

Testing Jupyter Notebooks

The more you do programming, the more you will here about how you should test your code. You will hear about things like Extreme Programming and Test Driven Development (TDD). These are great ways to create quality code. But how does testing fit in with Jupyter? Frankly, it really doesn’t. If you want to test your code properly, you should write your code outside of Jupyter and import it into cells if you need to. This allows you to use Python’s unittest module or py.test to write tests for your code separately from Jupyter. This will also let you add on test runners like nose or put your code into a Continuous Integration setup using something like Travis CI or Jenkins.

However all is now lost. You can do some testing of your Jupyter Notebooks even though you won’t have the full flexibility that you would get from keeping your code separate. We will look at some ideas that you can use to do some basic testing with Jupyter. Continue reading Testing Jupyter Notebooks

How to Export Jupyter Notebooks into Other Formats

When working with Jupyter Notebook, you will find yourself needing to distribute your Notebook as something other than a Notebook file. The most likely reason is that you want to share the content of your Notebook to non-technical users that don’t want to install Python or the other dependencies necessary to use your Notebook. The most popular solution for exporting your Notebook into other formats is the built-in nbconvert tool. You can use nbconvert to export to the following formats:

  • HTML (–to html)
  • LaTeX (–to latex)
  • PDF (–to pdf)
  • Reveal JS (–to slides)
  • Markdown (md) (–to markdown)
  • ReStructured Text (rst) (–to rst)
  • executable script (–to script)

The nbconvert tool uses Jinja templates to convert your Notebook files (.ipynb) to these other static formats. Jinja is a template engine for Python. The nbconvert tool depends on Pandoc and TeX for some of the conversions that it does. You may need to install these separately on your machine. This is documented on ReadTheDocs. Continue reading How to Export Jupyter Notebooks into Other Formats

Jupyter Notebook Extension Basics

There are several methods of extending the functionality of Jupyter Notebooks. Here are four of them:

  • Kernels
  • IPython kernel extensions
  • Notebook extensions
  • Notebook server extensions

For the purposes of this article, I will be focusing on the third item, Notebook Extensions. However, let’s take a moment and talk about the other three so that you are aware of how they can affect your Notebook. Continue reading Jupyter Notebook Extension Basics

Creating Presentations with Jupyter Notebook

Jupyter Notebook can be turned into a slide presentation that is kind of like using Microsoft Powerpoint, except that you can run the slide’s code live! It’s really neat how well it works. The only con in my book is that there isn’t a lot of theming that can be applied to your slides, so they do end up looking a bit plain.

In this article, we will look at two methods of creating a slideshow out of your Jupyter Notebook. The first method is by using Jupyter Notebook’s built-in slideshow capabilities. The second is by using a plug-in called RISE.

Let’s get started!

Note: This article assumes that you already have Jupyter Notebook installed. If you don’t, then you might want to go to their website and learn how to do so. Continue reading Creating Presentations with Jupyter Notebook

Jupyter Notebook 101: Writing Update

I don’t usually write about my book writing while the book is in progress on my blog, but I know some readers probably wonder why there are times where I am not writing blog posts as regularly as I usually do. The reason is usually because I am deep into writing chapters for a book and if the book’s chapters don’t translate into good blog articles, then the blog itself doesn’t get a lot of new content.

Anyway, as you may know, I am currently working on a book called Jupyter Notebook 101 which I am currently planning to release in November. I have 7 of the planned 11 chapters finished, although I plan to go over the entire book and check it for errors once it’s done. I am hoping to get the other chapters done early so I can write a few bonus chapters too, but we will see how the writing goes. On the plus side, these latter chapters will make good blog fodder, so you can expect to see some interesting articles on the Jupyter Notebook appearing on this blog in the near future.

If you’re interested in checking out the book, you can download a sample from Leanpub.

Jupyter Notebook 101: Table of Contents

I am about halfway through the Kickstarter campaign for my new book, Jupyter Notebook 101 and thought it would be fun to share my current tentative table of contents:

  • Intro
  • Chapter 1: Creating Notebooks
  • Chapter 2: Rich Text (Markdown, images, etc)
  • Chapter 3: Configuring Your Notebooks
  • Chapter 4: Distributing Notebooks
  • Chapter 5: Notebook Extensions
  • Chapter 6: Notebook Widgets
  • Chapter 7: Converting Notebooks into Other Formats
  • Chapter 8: Creating Presentations with Notebooks
  • Appendix A: Magic Commands

The table of contents are liable to change in content or order. I will try to cover all of these topics in one form or another though. I am also looking into a couple of other topics that I will try to include in the book if there is time, such as unit testing a Notebook. Some of my backers have also asked for sections on managing Jupyter across Python versions, using Conda and if you can use Notebooks as programs. I will look into these too to determine if they are within scope for the book and if I have the time to add them.