Limin
Limin

Reputation: 143

Why does the Jupyter notebook display as a JSON file in VS Code?

enter image description here

It works well when I use command + shift + P then 'jupyter:create a new project'.

For this file, I used that function. One day I close VS Code and I found the 'ipynb' looks like 'json' when I open it again.

How can I make it back to a jupyter notebook?

Upvotes: 6

Views: 14344

Answers (5)

Thomas Fritz
Thomas Fritz

Reputation: 340

Change the corresponding editor association in your user or profile settings (JSON) like so:

"workbench.editorAssociations": {
    "*.ipynb": "jupyter-notebook"
},

Upvotes: 0

SL4566
SL4566

Reputation: 132

This worked for me.

    "workbench.editorAssociations": {
        "*.ipynb": "jupyter.notebook.ipynb", // if commented, will open as JSON
        // "*.ipynb": "default" //do not turn it on else will not open JupyterNB by default

Upvotes: 6

Joseph M.
Joseph M.

Reputation: 81

When Saving your notebook pick "All Files" instead of JSON. Pick All Files

Your file will show up as a IPYNB

Your file will show up as a IPYNB

Upvotes: 0

LBF
LBF

Reputation: 1

Change back the extension from a .json to .ipynb

Upvotes: -4

Gino Mempin
Gino Mempin

Reputation: 29560

  1. Check that you are using the correct Jupyter extension.

    The old donjayamanne.jupyter extension has now been merged into or replaced by the ms-toolsai.jupyter extension. Searching for "jupyter" in the extensions list should show both of them, with one of them marked as "(deprecated)".

    enter image description here

    If you still have the deprecated one, uninstall that, and install the new one. As mentioned in the old extension's description:

    This extension is no longer being maintained and all of its functionality has been (or will be) placed into the Microsoft Jupyter extension.

    Please download the Microsoft Jupyter Extension instead.

  2. Check that you have Use Notebook Editor enabled.

    From Setting up your environment:

    By default, the Visual Studio Code Python extension will open a Jupyter Notebook (.ipynb) in the Notebook Editor. If you want to disable this behavior you can turn it off in settings. (Python > Data Science: Use Notebook Editor

    The docs still mention the old setting, but as of VS Code 1.54 and with the new Microsoft Jupyter extension, it should now be:

    "jupyter.useNotebookEditor":true
    

    enter image description here

  3. Check that you activated a Python environment with the Jupyter package.

    From Setting up your environment:

    To work with Jupyter notebooks, you must activate an Anaconda environment in VS Code, or another Python environment in which you've installed the Jupyter package. To select an environment, use the Python: Select Interpreter command from the Command Palette (+SHIFT+P).

    Open a terminal and check that you have jupyter and ipykernel:

    (venv) test$ jupyter --version
    jupyter core     : 4.7.1
    jupyter-notebook : not installed
    qtconsole        : not installed
    ipython          : 7.21.0
    ipykernel        : 5.5.0
    jupyter client   : 6.1.11
    jupyter lab      : not installed
    nbconvert        : not installed
    ipywidgets       : not installed
    nbformat         : not installed
    traitlets        : 5.0.5
    

    The Jupyter extension requires you to install ipykernel:

    (venv) test$ pip install ipykernel
    

Upvotes: 4

Related Questions