Join us and get access to hundreds of tutorials and a community of expert Pythonistas.

Unlock This Lesson

This lesson is for members only. Join us and get access to hundreds of tutorials and a community of expert Pythonistas.

Unlock This Lesson

Hint: You can adjust the default video playback speed in your account settings.
Hint: You can set the default subtitles language in your account settings.
Sorry! Looks like there’s an issue with video playback 🙁 This might be due to a temporary outage or because of a configuration issue with your browser. Please see our video player troubleshooting guide to resolve the issue.

Jupyter Notebooks Extensions

Give Feedback

Jupyter allows you to add new functionality to Notebooks through extensions. In this lesson, you’ll see where to get extentions, how to install them, and how to enable and disable them using an extension manager.

Download

Course Slides (PDF)

414.8 KB

00:00 The last point I want to talk about in this tutorial are Jupyter Notebook extensions. There’s a whole lot of them, and I’m going to show you the easiest way to get started exploring them.

00:12 So, we head over to our terminal that we opened up using Jupyter. And in here, I’m just going to copy-paste pip install for jupyter_contrib_nbextensions.

00:24 You can find the GitHub link to this repository also in the written tutorial. This is just going to install a couple of extensions that are useful and that we’re going to try out.

00:40 Okay, so I already had those installed, that’s why it’s coming up as already satisfied, but otherwise it would have installed this. And the next thing we’re going to grab is a Notebook extensions configurator, which is a useful tool for enabling and disabling specific extensions without having to do it from the command line.

01:01 So, I’m also fetching this from GitHub and just copy-pasting to install here.

01:08 All right, this is done. And the last thing I need to do now is I need to enable this Notebook extension. Generally, you would have to do this with every single one of the extensions, but using this extension manager, we’d only need to activate this one and then we can do the rest of them through a graphical user interface.

01:31 Here’s the command to enable it. We’re using a jupyter command for this, jupyter nbextensions_configuratorso, that would be the name of whatever extension you want to activate—and then you say enable to activate it, disable for disabling it.

01:46 And we’re just going to do this for our --user.

01:53 After calling this, it’s telling us that “Fine, okay, this extension is now enabled,” and now we’ll have to restart Jupyter Notebooks in order to be able to use the extension.

02:04 So I’ll go ahead and do that from my command line.

02:15 Now restart it…

02:27 And here we are. We see now the Nbextensions tab here on our Notebook server. I’ll go ahead and click that. And here you can see a long list of pre-installed extensions that came with this package that we downloaded from GitHub. There’s a lot of them.

02:44 Most of them I don’t know. I tried out some of them and want to just show you two or three so that you have an idea of what you’re able to do with these extensions, and then I’d just encourage you to go ahead and explore. And these are by far not all of them. The community built a lot of other extensions, and if you’re savvy with JavaScript, just go ahead and build your own.

03:09 I’m going to activate Scratchpad, and that just works through clicking here, and I’m going to activate the Variable Inspector. You can also read up on what does it do down here.

03:21 The Variable Inspector collects all the variables, and you can take a look at them and what’s currently defined. That sounds useful. And yeah, there’s a lot of them. I just encourage you to try them out.

03:34 There’s syntax highlighting, there’s code autocompletion, there’s PEP8 linting. There’s an extension that allows you to publish your Notebook as a Gist right away. Let’s activate that too, and go over to our Notebook to take a look.

03:56 Since I restarted the Notebook server, I also have to start the kernel for our Notebook again. I restructured it a bit, took away most of the Markdown. And here, now we can see—after activating these extensions—I can see these things popping up here, and one of them is down here.

04:14 So, what do we have? I’m going to run these two cells, so I put these two variables in memory, and now using the Variable Inspector I can take a look in this floating window—I can move it around—and it tells me what’s the current value of all of the different variables that are currently defined inside of my Notebook. I can sort them by Name, Type, Size, or Value. So, that’s one example. Then there’s the Scratchpad, which essentially, from what it seems, is just a mini Notebook, right in here.

04:51 I can create variables in here, execute them in the same way that I do without Notebook extensions. Print out, play around, and try it out. And these variables that I define in here are even available inside of the Notebook afterwards, so I could go ahead and print out b.

05:17 Another extension that could be fun and helpful for some people is this Gist-it. I can just click this button and then right from here, create a public Gist. There’s a possibility also to sign in with your account, to then have the Gist associated to your GitHub account.

05:38 So, I guess it requires authentication to create a Gist. So, these are just some quick examples of possible ways that you can extend your Jupyter Notebooks. As you saw, there’s a lot of them and there’s many more.

05:56 If you’re interested, if there’s something specific that you want, go ahead and take a look if it exists, or otherwise write it yourself and contribute to the community.

06:05 There’s probably some people who are going to be thankful for it.

06:11 This wraps up this short tutorial on getting started using Jupyter Notebooks. I hope you enjoyed it, and I hope I inspired you to go ahead and explore a little. See you next time!

carzap96 on April 20, 2019

Thanks for the quick tutorial

Nagaraj on April 23, 2019

Is there a way I can export the notebook without the python code appearing in the export? for e.g. something like you can do with R Studio wherein you can create R Markdown presentations with charts and user written comments in markdown, but turn off the R code from printing in the final document/presentation which generated the charts?

Milan NIkolic on May 21, 2019

Thank you for a nice and brief tutorial. Great one!

FAISAL AMEEN on Sept. 13, 2019

very informative .. Thanks!!

azmathias on Nov. 7, 2019

Thank you for the excellent tutorial. Will be using the extensions knowledge I have gained in future development.

benedictberty on Dec. 1, 2019

I dont know why I can see nbextensions after installing it

Martin Breuss RP Team on Dec. 2, 2019

Try to restart Jupyter notebooks from the command line after installing nbextensions.

Lipsa on Dec. 16, 2019

Hi Martin,

My name is Lipsa and i am absolute beginner. i may ask may questions, i hope its okay. when i am trying to install jupyter in command prompt i get below error.

Microsoft Windows [Version 10.0.18362.476] (c) 2019 Microsoft Corporation. All rights reserved.

C:\Users\Lipsa Patro> pip install command prompt ‘pip’ is not recognized as an internal or external command, operable program or batch file.

C:\Users\Lipsa Patro>

Please advise on same and also share some cool tips.

Martin Breuss RP Team on Dec. 17, 2019

Hello @Lipsa and welcome to the community :)

This message tells you that you currently don’t have pip installed on your system. You can read more about it here in What is Pip.

This Python 3 Installation & Setup Guide might also be useful. Alternatively, you could install Miniconda that already includes an installation of Jupyter notebooks.

Hope that helps!

aradim on Dec. 23, 2019

Thanks , very helpfull

Vikrant on Dec. 26, 2019

Hi Martin, I’m not able to view the extensions under the Nbextensions tab. Details below:

  • I’ve installed Jyupter notebooks via Anaconda package and after following the commands you’ve given I’ve installed the intended packages.
  • After restarting the Jyupter though I can see the intented tab i.e. Nbextensions but I’m not able to see the extensions
  • I’m on Windows 10 OS and Notebook version is 6.0.1

Could you guide me or suggest me a way through I can see the intended extensions please ? Let me know in case more details are required from my end.

Martin Breuss RP Team on Dec. 26, 2019

Hello @Vikrant. Double-check that you installed the package jupyter_contrib_nbextensions and that you have activated at least one of the extensions with jupyter nbextension enable EXTENSION_NAME. See also the section in our written tutorial.

Since you might not know the name of the extension you want to enable beforehand, I suggest to use the Jupyter Nbextensions Configurator (as described in the video). If you install and enable it, you should be able to see all the extensions that came with the package you installed previously. Hope this helps!

Vikrant on Dec. 27, 2019

Thanks I was able to resolve the issue. Basically, I had duplicate extenstions. However, I’d like to know if you have checkbox i.e. disable configuration for nbextensions without explicit compatibility (they may break your notebook environment, but can be useful to show for nbextension development) in unchecked state to use the extensions?

Martin Breuss RP Team on Dec. 29, 2019

Yes, that checkbox:

disable configuration for nbextensions without explicit compatibility (they may break your notebook environment, but can be useful to show for nbextension development

currently needs to be unchecked so that you can use the extensions.

mrx on Dec. 30, 2019

Thanks Martin but the box is unticked. Im just guessing the anaconda package includes these extensions and I just doubled them? Thank you for reporting back Vikrant I will see if I have doubles…

Vikrant on Dec. 30, 2019

@mrx In case you’re also running Jyputer via Anaconda then probably it’s worth checking the error logs on the terminal (Jupyter Notebook (Anaconda3): in my case) for any errors i.e. duplicates.

It took me an hour to figure out the issue. docs.anaconda.com/anaconda/user-guide/tasks/use-jupyter-notebook-extensions/#obtaining-the-extensions

Basically I had two issues. 1st the exentions were not available under the intended tab 2. After following the instructions provided in this tutorial correctly I was able to view the extentions however they were disabled.

Upon checking logs on the anaconda terminal I figured out that I had dupicates and I was able to remove them via uninstall command following the instructions provided in the above link

I hope this would help in troubleshooting the issue related to duplicates. Also, in case anybody has installed Jyputer via Anaconda then I believe they have to just enabled the Tab as the extensions are already present (no need to download)

Martin : Please correct me in case I’m wrong with my analysis. Also, if you could add somewhere in the tutorial i.e. how to enable the extensions in case users are using Anaconda installtion for running the jyputer then I believe it would be helpful for the students.

mrx on Dec. 30, 2019

@Vikrant Your awesome, I think people are going to benefit from your solution! I had the same thing going on, but when I started out here I plugged in a USB HDD and installed Ubuntu 18.04 just because I knew I would likely screw things up! So I removed Anaconda and upgraded to 19.04. there was no difference between the package holder .conf and my system.conf, but added the new .conf anyway. I was injured at work, and cannot return to my old job, so with me it is sink or swim!I am going to take the KISS (keep it simple) route and only install what is needed to learn the base language for now (of coarse Jupiter too). I appreciate people like yourself, and Martin (great Tut BTW :) ) If you would like to remove my posts please do so.I will find a seat in the back of the class ;) Happy holidays!

Martin Breuss RP Team on Jan. 4, 2020

Thanks for your deep-dive with the extension-collision when using the Anaconda Python distribution @Vikrant, and thanks for confirming that Vikrant’s approach resolved your issue as well @mrx. Very helpful 👏!

We’ll add a note to this tutorial section to inform others about this situation. :)

kwf777 on Jan. 15, 2020

I think it woud be helpful to have an in-depth tutoril on Jupyter Notebook . This was good but would like more information.

pashikkalenik on Feb. 26, 2020

Hi Martin. Would you provide the command to restart Jupyter Notebook from command line, please?

Ricky White RP Team on Feb. 26, 2020

Hi @kwf777. We have a in-depth tutorial on Jupyter Notebook’s here: realpython.com/jupyter-notebook-introduction/

Martin Breuss RP Team on March 1, 2020

Hi @pashikkalenik. You can go into your command line and press Ctrl+c to stop the Notebook Server. Then you can restart it with the normal start command:

jupyter notebook

thomasknebel on March 29, 2020

Hi,

How to end a jupyter notebook when I run it locally and when shall I use the “Quit” and “Logout” button?

Best regards, Thomas

Martin Breuss RP Team on March 29, 2020

Hi @thomas. There really are a couple of options here and they can be confusing. Here’s what I think:

Terminal

When running your notebook server locally, you can stop it by pressing Ctrl+C in your terminal. This is what I do. It shuts down the whole notebook server and thereby ends your session of working with the any Jupyter app you may have running.

Quit Button

Pressing the “Quit” button is equivalent to shutting down the server through your terminal. When you hover over the button it gives you some info indicating that:

Stop the Jupyter server

Logout Button

This one is a bit more confusing 🤔 It’s easier to understand I think when you think of Jupyter notebooks as a webapp. It runs on a server (whether that’s locally or remotely) and as such you can have sessions that you are logged in to.

When you start a new server locally, it gives you some hints to that effect:

[I 14:34:31.614 NotebookApp] JupyterLab application directory is /your_path
[I 14:34:31.618 NotebookApp] Serving notebooks from local directory: /your_path
[I 14:34:31.618 NotebookApp] The Jupyter Notebook is running at:
[I 14:34:31.618 NotebookApp] http://localhost:8888/?token=9819a2dd9bb34f5844a1e8e0da9fc3d45e55f7cba07411dd
[I 14:34:31.618 NotebookApp] Use Control-C to stop this server and shut down all kernels (twice to skip confirmation).
[C 14:34:31.630 NotebookApp] 

    To access the notebook, open this file in a browser:
        file:///Users/martin/Library/Jupyter/runtime/nbserver-1799-open.html
    Or copy and paste one of these URLs:
        http://localhost:8888/?token=9819a2dd9bb34f5844a1e8e0da9fc3d45e55f7cba07411dd
     or http://127.0.0.1:8888/?token=9819a2dd9bb34f5844a1e8e0da9fc3d45e55f7cba07411dd

Notice the token mentioned here. This token is your login to the notebook server.

Therefore, if you press the “Logout” button, Jupyter brings you to a page that prompts you to log back in (just like a webapp would). You can log back in by copy-pasting the token from your terminal into the input box and voilà you’re back in your notebook session. 🙂

prajeecool on April 2, 2020

Hi Martin, Thanks for this session. It has been really good. I have one concern. I followed the steps mentioned by you for Nbextensions. I could see the tab for Nbextensions in my Jupyter Home page. But i don’t see any extensions under them.

jupyter-js-widgets/extension

Nbextensions dashboard tab

Nbextensions edit menu item

Martin Breuss RP Team on April 2, 2020

Hi @prajeecool, did you follow the checks I outlined in a comment further up:

Double-check that you installed the package jupyter_contrib_nbextensions and that you have activated at least one of the extensions with jupyter nbextension enable EXTENSION_NAME. See also the section in our written tutorial.

Since you might not know the name of the extension you want to enable beforehand, I suggest to use the Jupyter Nbextensions Configurator (as described in the video). If you install and enable it, you should be able to see all the extensions that came with the package you installed previously. Hope this helps!

If these steps don’t solve it, please describe in more detail what you did and what you can see and can’t see. We’ll figure it out! :)

astrid on June 1, 2020

Hi Martin,

Thanks for your lesson. I am unable to get the same list of extensions that you had in your video. Please help me. I have explained my situation below.

I followed you all the way until video timestamp 02:04. Up till that point, I had used a terminal in Jupyter to input the following commands: pip install jupyter_contrib_nbextensions pip install jupyter_nbextensions_configurator jupyter nbextensions_configurator enable –user

From 02:04, I was lost. I have no idea how you used your command line to restart Jupyter. I don’t know where is this “command line”; is a command line the same as a terminal that I create in Jupyter? If so, could I have used the same terminal, in which I input the above 3 commands, to execute the Jupyter restart? I also have no idea what commands you input, as seen in 02:18.

As I was unable to locate the command line and restart Jupyter the way you had in the video, what I did was I closed all Jupyter tabs and my Anaconda Navigator as well. I was hoping that this was the same as restarting Jupyter, but it did not work. It did not work because I cannot see the long list of nbextensions.

I also followed @Vikrant’s advice. With reference to docs.anaconda.com/anaconda/user-guide/tasks/use-jupyter-notebook-extensions/#obtaining-the-extensions, I used a Jupyter terminal to input the command “conda install nb_conda”.

The final result was that I only have this extension “Nbextensions edit menu item”, which I don’t know how to use.

Please help me get the same list of extensions as shown in your video. In particular, I am interested in getting the Variable Investigator and Scratch Pad. Thank you.

drcarrollmba on June 2, 2020

I second everything that limyuyvette said! I have the exact same issues.

astrid on June 2, 2020

@drcarollmba, let’s hope that Martin helps us soon :) By the way, Martin, to avoid confusion, I am limyuyvette (I recently changed my username to “astrid”).

Geir Arne Hjelle RP Team on June 2, 2020

I believe that Martin had two terminals open. The words “terminal” and “command line” are used interchangeably and (essentially) mean the same thing.

If you you use Anaconda on Windows you can get a command line by starting the Anaconda enabled command prompt, either from the start menu or from within Anaconda Navigator.

If you started Jupyter from within Anaconda Navigator, I don’t think you will have a terminal with the Jupyter log inside (like the one Martin shuts down at about 2:05). Instead, you can restart Jupyter by using the shut-down commands in the menu inside Jupyter. And then starting it again like you usually do - for instance from Anaconda Navigator.

drcarrollmba on June 3, 2020

Geir Arne Hjelle, thank you, that helps!

astrid on June 6, 2020

Geir Arne Hjelle, thank you for your help!

For those who still cannot install the nbextensions, you can try this link: www.youtube.com/watch?v=-6HmdijtWwk

I was able to succeed with installation using this link.

Become a Member to join the conversation.