Features Tips & Tricks

Feature Spotlight: IPython Notebook inside an IDE

Happy Friday everyone,

This week I’d like to shed some light on the recently introduced IPython Notebook integration in latest PyCharm 4 which was announced a couple of weeks ago:

ipynb2This feature is considered to be the most important among other cool features that appeared in the latest release, and there is a reason behind it – IPython Notebook is very popular computational environment, and is an extremely useful solution for a wide range of tasks. There is no need to explain how great it is for scientists and data analysts and how convenient it is for learning programming or just showing off some topics or code snippets complemented with texts, graphics, mathematics and plots. It works great for so many people!

The PyCharm team is committed to make great things even better and to provide an extra value for Python programmers at large, so we eventually decided that we can integrate with IPython Notebook and deliver the solution that combines the advantages of IPython Notebook with extra benefits that the most intelligent Python IDE can offer.

Shortly, PyCharm allows you to open and modify *.ipynb files and run them using a standard IPython Notebook kernel. So lets take a look on how it works inside PyCharm.

Setting things up

Note: If you’re new to PyCharm, I recommend you to read the Quick Start Guide and Getting Started with PyCharm tutorials first.

Consider you already have IPython Notebook files somewhere on your filesystem and would like to work with them using PyCharm. For that, just open the directory containing the files with File | Open when using PyCharm:


Note: With PyCharm you can create new *.ipynb files from scratch. In this example I use File | Open for simplicity.

After that you’ll be able to open the files for editing from the Project View:


To make things working, you first need to specify the project interpreter that will be used for running the code in your *.ipynb files. You can do it in Settings(Preferences for Mac OS) | Project | Project Interpreter. Here you’ll need to check the desired interpreter by choosing from the list of autodetected interpreters or discover it manually. PyCharm also helps you to quickly create virtual environments and manage them. When you’ve selected the right interpreter or virtual environment please make sure you have all the necessary packages installed. For my demo, I already have IPython installed on the virtual environment with other dependencies necessary for IPython Notebook. In case some packages are not installed, please use the integrated package manager to install what is needed:


Running code

Now we’re all set and ready to start coding with IPython Notebook. Click on the cell and then click on the run icon in the special IPython Notebook toolbar right on top of the editor:


PyCharm will offer to start the IPython Notebook Kernel automatically and will provide you with an URL where the IPython Notebook kernel will run:


Click OK and in short time you’ll be notified that IPython Notebook started at the URL provided:


From this point you can work with IPython Notebook as usual. PyCharm supports all the basic functionality of ordinary IPython Notebook. The latest format of IPython Notebook files is also supported. You can add new cells, cut and paste them, run arbitrary cells, and change their type. We’ve tried to preserve the similar behavior of ordinary IPython Notebook as much as possible – you can edit and review mathematical formulas in LaTeX, output plots and different graphics, and do other usual actions:


In this blog post I’m not going to cover each aspect of the IPython Notebook integration – instead, I’ll answer the 2 most frequent general questions about this new functionality:

What’s the reason to use PyCharm over classic IPython Notebook?
The main advantage is that PyCharm brings the intelligence and all the additional advantages of an IDE when working with IPython Notebook files. That means you get a code autocompletion, error detection, on-the-fly code fixes and suggestions, navigation and refactorings, local history, VCS support, and a lot more. So basically you get all the neat stuff that makes any developer who uses PyCharm more productive:


There’s also a number of extra features that are not present in classic IPython Notebook, but will be implemented in future versions, like running all cells in one click.

What’s not supported yet?
There is a number of IPython Notebook features that are not supported yet, like interrupt/reload kernel actions, html injections, export to .py files, and some other. After releasing the first version of IPython Notebook integration, we’ve got a bunch of suggestions, bugs and feature requests in our issue tracker. And we’re planning to significantly improve this integration for the next version of PyCharm.

I’d like to encourage you to start using the IPython Notebook integration right away and if you have any problems or suggestions, please file them to our tracker. It’ll help us fix the problems and implement new features even faster.

And here’s some more great news: IPython Notebook integration is supported in PyCharm Community Edition, which means everybody can use it for free!

In this blog post we touched just a tip of the IPython Notebook integration iceberg. Please try it in action and give us your feedback in our forum and the public issue tracker!

Here you can find a complete tutorial for using IPython Notebook with PyCharm.

See you next week!

Comments below can no longer be edited.

27 Responses to Feature Spotlight: IPython Notebook inside an IDE

  1. Avatar

    David says:

    December 6, 2014

    “For my demo, I already have IPython installed on the virtual environment with other dependencies necessary for IPython Notebook. In case some packages are not installed, please use the integrated package manager to install what is needed:”

    I use IPython Notebooks, but I haven’t used PyCharm before. I downloaded and installed it so I could follow along with this article, but this is the point at which I stopped.

    Since I’m using IPython Notebooks independently, I assume I have all the necessary dependencies installed, but PyCharm’s Project Interpreter page doesn’t list it as a package. When I invoke IPython from the command line, it calls a script which sets up the environment and calls ipython.exe, but neither the script nor ipython.exe seem to be the “package” that PyCharm wants.

    As someone who has not used PyCharm before, I just thought I’d give you a heads up that this article doesn’t really help me get started, and doesn’t provide a link to where I might find out more about the “integrated package manager”. I’ll check out the “complete tutorial” listed at the end of the article to see if that’s more helpful.

    I understand that the focus of this article is probably existing PyCharm users who just want to learn how to use this new feature, but I suspect even some of them might not be familiar with the integrated package manager and how to create a project interpreter. I could be wrong.

    • Avatar

      Dmitry Filippov says:

      December 8, 2014

      Hi David,

      thank you for your feedback on this article!
      Indeed, there is no any guideline for those who are new to PyCharm in this post.
      I’m going to update this post adding links to some basic getting started tutorials in the beginning.
      There’re 2 jump starting tutorials for PyCharm:
      1. http://confluence.jetbrains.com/display/PYH/Exploring+the+IDE.+Quick+Start+Guide – Explains some general concepts.
      2. http://confluence.jetbrains.com/display/PYH/Getting+Started+with+PyCharm – Step-by-step guide creating and running a project from scratch.

      You can read about the “integrated package manager” here:
      See “Project Interpreter, Local interpreter, Virtual environment, Packages and paths” sections.

      IPython is a wrapper around a Python interpreter and normally is being installed as a package for a Python interpreter. So please ensure that you’ve selected a correct Python interpreter with IPython installed and that the other packages required to run IPython Notebook are also installed: Jinja2, pyzmq, tornado.
      You can review and install everything using the integrated package manager.
      There can be several interpreters on your system and probably your PyCharm uses an interpreter without ipython by default. So please choose the right one and install everything missing.
      Hope this helps!

  2. Avatar

    Kyle Kelley says:

    December 6, 2014

    From reading this, it sounds like you’re actually running a full notebook server when you could connect directly using ZeroMQ to a running kernel and use all the existing open specs for communication and display. My primary reason for wanting this is so you don’t have to run a full blown IPython/tornado server on someone’s local machine (to lower overall risks).

    • Avatar

      ktisha says:

      December 10, 2014

      Hi Kyle,

      in case you have running Ipython server you could specify it’s URL in Settings->Tools->Ipython Notebook. PyCharm will connect to a running instance using ZeroMQ.

  3. Avatar

    Bastian says:

    December 17, 2014

    Is it possible to do that with intellij idea 14 ?

    • Avatar

      Dmitry Filippov says:

      December 17, 2014

      We’re releasing the updated Python plugin for IDEA 14 very soon and it will support IPython Notebook.

      • Avatar

        Bastian says:

        December 18, 2014

        Great.. thanks 😉

  4. Avatar

    Daniel says:

    December 25, 2014

    Great set of features. Looking forward to the plugin for IDEA 14. Will it be released in the next 2 weeks?

    • Avatar

      Dmitry Filippov says:

      December 26, 2014

      We’re going to release it very soon!

  5. Avatar

    Martin Bless says:

    January 18, 2015

    That’s breathtaking! Thank you for these great features and – keep on!

  6. Avatar

    Jon Tirsen says:

    March 9, 2015

    This is really awesome. When I change the Python code the notebook doesn’t get reloaded. Does anyone know how to restart the Python process to reload the code?

  7. Avatar

    Hojjat says:

    May 1, 2015

    Hi Dmitry,

    Thanks for the cool tutorial! I have some problems with the IPython notebook in PyCharm, which I hope you can help:

    1) when I insert a latex formula, it shows that as an image with broken link in the cell!
    2) I cannot run python codes in the cell.
    3) Instead of “ln[.]” where “.” is the line number, I have “ln[*]”!


  8. Avatar

    Riki says:

    September 12, 2015

    I’m using PyCharm 4.5.4 and facing some problem with ipython. Actually nothing comes out in the output. My guess is that it is associated with PyCharm’s ipython plugin. iPython works very well with web browser. I’m using anaconda’s python packages. Everything is installed for ipython.

    IPython Notebook run gives:
    /Users/riki/Applications/anaconda/bin/python /Users/riki/Applications/anaconda/bin/ipython notebook –no-browser –ip –port 8888
    [W 01:47:47.415 NotebookApp] ipywidgets package not installed. Widgets are unavailable.
    [I 01:47:47.436 NotebookApp] Serving notebooks from local directory: /Users/riki/PythonProjects
    [I 01:47:47.436 NotebookApp] 0 active kernels
    [I 01:47:47.436 NotebookApp] The IPython Notebook is running at:
    [I 01:47:47.436 NotebookApp] Use Control-C to stop this server and shut down all kernels (twice to skip confirmation).
    [W 01:47:49.849 NotebookApp] 404 GET /api ( 25.85ms referer=None
    [I 01:47:49.879 NotebookApp] Kernel started: 1071a698-99ca-4218-b8dd-28e7168ef2f8
    [W 01:47:49.894 NotebookApp] 404 GET /api/kernels/1071a698-99ca-4218-b8dd-28e7168ef2f8/shell ( 2.03ms referer=None
    [W 01:47:49.898 NotebookApp] 404 GET /api/kernels/1071a698-99ca-4218-b8dd-28e7168ef2f8/iopub ( 1.53ms referer=None

    Python console gives:
    /Users/riki/Applications/anaconda/bin/python -u /Applications/PyCharm.app/Contents/helpers/pydev/pydevconsole.py 50572 50573
    /Users/riki/Applications/anaconda/lib/python3.4/site-packages/IPython/utils/traitlets.py:5: UserWarning: IPython.utils.traitlets has moved to a top-level traitlets package.
    warn(“IPython.utils.traitlets has moved to a top-level traitlets package.”)
    Python 3.4.3 |Anaconda 2.3.0 (x86_64)| (default, Mar 6 2015, 12:07:41)
    Type “copyright”, “credits” or “license” for more information.

    IPython 4.0.0 — An enhanced Interactive Python.
    ? -> Introduction and overview of IPython’s features.
    %quickref -> Quick reference.
    help -> Python’s own help system.
    object? -> Details about ‘object’, use ‘object??’ for extra details.
    PyDev console: using IPython 4.0.0

    import sys; print(‘Python %s on %s’ % (sys.version, sys.platform))

    Python 3.4.3 |Anaconda 2.3.0 (x86_64)| (default, Mar 6 2015, 12:07:41)
    [GCC 4.2.1 (Apple Inc. build 5577)] on darwin

  9. Avatar

    Alex says:

    May 20, 2016

    ALL these tutorials are FU*CKING OUTDATED! ALL of them!

    This is a commercial product! I paid for it and the support simply stinks!
    There’s not a single document around regarding this IDE that is true to the current version of the product, which obviously changed many elements of its UI/UX to which I’m entirely new to, and therefore completely lost!

  10. Avatar

    Graham says:

    September 16, 2016

    After a bit of a struggle all working well now. Looks good generally, but the margins on the left and right are sooooo large it makes it impossible to use properly on a small laptop screen.

    Can these margins be shrunk? otherwise it’s back to the browser unfortuantely 🙁

    • Avatar

      Dmitry Filippov says:

      September 20, 2016

      Thank you for the feedback. Currently it’s not possible to adjust margins. With the next PyCharm release we’re going to rework Jupiter integration.

  11. Avatar

    Miles says:

    February 12, 2017

    One can stop and start jupyter servers in a given virtual environment, but it would be nice if PyCharm offered a way to select the desired kernel aside from the base kernel, like Jupyter does. Different projects requiring the use of different kernels. Also, PyCharm is fantastic regardless. 🙂

    • Avatar

      Miles says:

      February 12, 2017

      To clarify why this would be nice; you have one jupyter server running in the base environment and co-workers can login and select the given kernel they want from the Jupyter UI. Thus it would be nice if PyCharm could support choosing a specific kernel as well. 🙂

  12. Avatar

    RM says:

    February 16, 2017

    I’ve just started using Jupyter/iPython notebooks in PyCharm (PyCharm 2017.1 EAP
    Build #PY-171.3019.3, built on February 7, 2017) and have noticed that a lot of the features that make PyCharm useful are somewhat broken in a Notebook because PyCharm seems to limit a lot of functionality to a single cell.

    For example, alt+enter on a missing module import will import it at the top of the current cell, rather than the top cell of the page, so that your imports will be randomy scattered around your notebook. Ctrl+f will only find things in the current cell. The current cell might be a single line of code, I don’t want to ctrl+f that! Ctrl+Q fails to find the source code for an import unless that import is imported in the current cell. If the import isn’t at the top of the current cell, PyCharm takes me to code.py, which is a file holding just the code for the current cell. That’s worse than useless.

    Unless you have a single cell for your entire notebook, this seriously limits the advantages of having an IDE.

    Maybe I should submit all this stuff as a feature request?

    Anyway, thanks for making a great IDE, here’s hoping that we can work together to make it even more awesome.

  13. Avatar

    Valentine Kiryushkina says:

    February 20, 2017

    Hi, RM!
    Thank you for your feedback!

    We know about the problem with imports on alt+enter and plan to fix it in a future during our Notebook re-implementation.

    We have tickets for problems with Ctrl + f and Ctrl + Q: https://youtrack.jetbrains.com/issue/PY-14087

  14. Avatar

    Maarten Fabré says:

    February 27, 2017

    Would it be possible to extend the search after refractoring to jupyternotebooks too?
    Now, when I change a method signature or rename a method in one of the libraries I made, the refractoring searches for occurrences in python scripts and documentation, but not in jupyter notebooks which reside in the same directory as the python scripts.

  15. Avatar

    Go says:

    September 5, 2017

    Hi thank you for great tool to integrate Jupyter notebook into pycharm.

    I’m now trying to use it, however somehow I can’t find button which I can see in web interface.
    I can find “+” button, but not “scissors” button. So I can’t delete cells.
    Also I can’t find “save” button.

    May I know what I should change?
    my environment is
    Windows 7
    Pycharm 2017.2.2
    python 3.6
    ipython 6.1.0

  16. Avatar

    David MacMillan says:

    May 26, 2018

    This does not provide a clear step-by-step discussion of how to run an .ipynb. When I open an .ipynb for editing I get json displayed, not a rendered jupyter notebook. All the info I can find on Jetbrains seems to assume I want to create an ipynb from scratch – I can’t find anything that tells me how to run an existing Jupyter notebook from within PyCharm. The settings needed are unclear from the above description. For example the suggestion “Here you’ll need to check the desired interpreter by choosing from the list of autodetected interpreters or discover it manually. ” is pretty useless because what is missing is WHICH interpreter to check, or at least an example – is it Python 2.7 (or 3.x) OR is it ipython (or Jupyter)? This whole sequence looks like it was written by someone who already has it operating on their system. Start with a virgin installation of pycharm and write down step-by-step what is needed, including what to check, to run an existing .ipynb using Jupyter. Maybe provide a smaple .ipynb that can be run using these instructions. (Just to calibrate my experience, IU use Pycharm daily and I use Jupyter notebooks very frequently, but I am stumped on how to run Jupyter notebooks in Pycharm. Judging by the comments, it seems many other are struggling with this also. Your instructions should be crystal clear, not opaque. And they usually are. But not yet for this.)

Discover more