'How to open ipynb files on a Mac?

How to open an .ipynb file on a Mac and use it?

Which apps is needed for that or what are your recommendations?



Solution 1:[1]

You tagged this with so I'm answering in the context of Visual Studio Code.


VS Code has support for creating, opening/viewing, and running Jupyter notebooks (.ipynb files). Check out their complete tutorial from the VS Code docs: Working with Jupyter Notebooks in Visual Studio Code.

Visual Studio Code supports working with Jupyter Notebooks natively, as well as through Python code files. This topic covers the native support available for Jupyter Notebooks and demonstrates how to:

  • Create, open, and save Jupyter Notebooks
  • Work with Jupyter code cells
  • View, inspect, and filter variables using the Variable explorer and Data viewer
  • Connect to a remote Jupyter server
  • Debug a Jupyter notebook

If you just want to view/open a .ipynb file, just open it in VS Code like any other file.

enter image description here

If it doesn't open like that and you get a "weird" JSON-like file, make sure the setting "Jupyter: Use Notebook Editor" is enabled.

"jupyter.useNotebookEditor": true

enter image description here

If you need to be running cells, you'll need to setup your environment and install the Jupyter package.

You can let VS Code do all the initial setup steps for you. Open or create a .ipynb file, and try to run any cell. If your environment is not yet setup, it will show an error:

enter image description here

So click on that Install button to let VS Code install all the dependencies on the currently selected Python environment.

Or if you want to install it yourself, select and activate an environment, then:

$ pip install jupyter

Once the Jupyter package is now installed, you'll see that the "Jupyter Server" indicator at the top right is now activate. Now, you can run cells.

enter image description here


So basically, all you need to do is:

  1. Install VS Code
  2. Setup a Python environment
    • On mac OS, it already has Python 2 but I recommend not using that
    • Instead, I recommend installing Python 3 via Homebrew
  3. Install the Jupyter package
  4. Select the Python environment (with the Jupyter package)
  5. Open and edit .ipynb files

Solution 2:[2]

you need to install jupyter you can do it using: pip install jupyter and run it in terminal with the command jupyter notebook this will open a browser window where you can view and run juputer notebooks

You can also open these notebooks in pyCharm and Visual Studio Code (after installing the python extension from microsoft)

Solution 3:[3]

To quickly view an .ipynb file you can use the nbviewer-app.

Installation via Homebrew:

$ brew install --cask jupyter-notebook-viewer

Alternatively, you can also download the app directly.

Starting with Mac OS Catalina, you might have to open a terminal and run

xattr -d com.apple.quarantine /Applications/Jupyter\ Notebook\ Viewer.app

after installation because the app is not notarized by Apple [Source].

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1
Solution 2 Aakash Singh
Solution 3 D-Cru