How to open .ipynb file in Spyder?

Viewed 19701

without using iSpyder DOS shell commands, how can an .ipynb (Jupyter Notebook) be opened directly into Spyder on Windows? Even the online Jupyter Notebook site prompts for a relative directory path where the file is stored.

  • Why isn't there something that just loads the Notebook how it's supposed to look without typing a bunch of directory commands,
  • and why does Spyder's RUN button become greyed out when it loads the .ipynb file?
  • I have no idea what the .ipynb file format is compared to regular .py files

Opening lines of the .ipynb when loaded in Spyder are:

{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {
    "ExecuteTime": {

This does not look like python code whatsoever

3 Answers

You may check out https://github.com/spyder-ide/spyder-notebook

Once you install this, you can open native .ipynb files in spyder

From the website:

Spyder plugin to use Jupyter notebooks inside Spyder. Currently it supports basic functionality such as creating new notebooks, opening any notebook in your filesystem and saving notebooks at any location.

You can also use Spyder's file switcher to easily switch between notebooks and open an IPython console connected to the kernel of a notebook to inspect its variables in the Variable Explorer.

The jupyter notebook plugin currently works with Spyder 4.2.5 version and will not work with Spyder 5.X versions.

If you are using Spyder-5.x and therefore cannot use the Spyder-notebook plugin (see the other answers), an alternative is to export the .ipynb from Jupyter as an executable .py script first, then open the .py script in Spyder.

Jupyter->Files->Save and Export Notebook as->Executable script

The .py script produced preserves the ipython cells, using the

# In[<cell name or number>]:

syntax, for dividing the code into cells.

In Spyder, you can then right-click on the cell, and select Run cell to execute it in the Spyder console.

Beware, that all the cells (Code, Markdown, and Raw) are saved in the .py script. You may need to add '''block quotes''' around your Markdown and Raw cells, to prevent SyntaxErrors when running the .py script file.

Related