[PYTHON] Double-click to open ipynb file (Mac, Anaconda virtual environment)

A note on how you can double-click an .ipynb file on your Mac. As shown in the link below, you can create an application that starts jupyterlab with Automator and register it as the default application that opens the ipynb extension. HOW TO OPEN JUPYTER NOTEBOOKS WITH A DOUBLE CLICK (MAC OS) If you want to open it in the virtual environment of anaconda, you can not use it as it is (jupyterlab will open in the base environment), so I made a small change. Since the explanation of the above link is polite, only the changes are briefly described here.

  1. Open Automator.app
  2. New → Application
  3. Added "Run Shell Script" action
  4. Change the input passing method to "as an argument" (to get the path of the double-clicked file)
  5. Set the script to be executed as follows
variable="'$1'"
the_script='tell application "terminal" to do script "source activate my_env && jupyter lab '
osascript -e "${the_script}${variable}\""

The change from the link source is that source activate my_env && is added in the script.

image.png

  1. Save the created application.
  2. Right-click the ipynb file → "Get Info" → "Open with this application" to assign the created application.

reference To use Linux commands continuously

Related article: For Windows Open the ipynb file by double-clicking (Windows)

Recommended Posts

Double-click to open ipynb file (Mac, Anaconda virtual environment)
Double-click ipynb in windows + anaconda environment to open with jupyter-notebook
[5 steps] Apply anaconda virtual environment to VScode
From Python environment construction to virtual environment construction with anaconda
Build an Anaconda virtual environment
[Anaconda] Activate the virtual environment
[Python] Anaconda environment construction (installation, startup, virtual environment, package management) Mac environment
Anaconda environment construction on Mac (2018 version)
Building a virtual environment for Mayavi dedicated to Python 3.6, Anaconda, Spyder users
Unable to import packages installed in virtual environment with Anaconda on Windows 10
Try to build python and anaconda environment on Mac (by pyenv, conda)
How to read environment variables from .env file in PyCharm (on Mac)
[Python] Building an environment with Anaconda [Mac]
Change Python 64bit environment to 32bit environment with Anaconda
[Python] Create a virtual environment with Anaconda
How to prepare Python development environment [Mac]
Script to create a Mac dictionary file
How to add python module to anaconda environment
Creating a virtual environment in an Anaconda environment
Add a Python virtual environment to VSCode
Note: Start Anaconda, enter the Python virtual environment, and connect locally to MongoDB.
How to share a virtual environment [About requirements.txt]
For beginners to build an Anaconda environment. (Memo)
How to create a Python virtual environment (venv)
[Memo] Build a virtual environment with Pyenv + anaconda
[Node-RED] Execute Python on Anaconda virtual environment from Node-RED [Anaconda] [Python]
Flow of creating a virtual environment with Anaconda
Unable to open file for writing About sudo
Error running Jupyter Notebook in Anaconda virtual environment
Procedure to set hydrogen of atom (virtual environment)
[Note] How to create a Mac development environment
Use anaconda virtual environment with Zsh (problem fix)