Nathaniel Brown's

Trick To Keep Jupyter Always Running In The Background On MacOS

Written July 08, 2017

TL;DR: Run curl -L -A "Install Jupyter" | bash for jupyter lab or curl -L -A "Install Jupyter" | bash for jupyter notebook.


If you use the jupyter notebook or jupyter lab daily there is no reason you should have to start the server every time you want to use jupyter. You can use a launchagent to automatically start a background jupyter process when you login. Add a bookmark and jupyter lab is always just one click away in your web browser.


Launch agents are controlled with .plist files in a couple different locations. .plist files for a user's launch agents are stored in ~/Library/LaunchAgents/. There are other locations for system agents and things. I found the easiest way to learn about launch agents and launch daemons is to download LaunchControl and mess around. You can cross reference the more readable GUI representations in LaunchControl with the .plist files. Launch agents are similar to launch daemons except the run at login rather than on boot.


You can either use the jupyter notebook or jupyter lab, just make sure you have whichever you want to use installed (i.e pip install -U jupyterlab).

Open up Terminal and run curl -L -A "Install Jupyter" | bash. If you don't want to run a random script (and you really shouldn't) go ahead and read it first at or below. If you want jupyter and not jupyter lab, run this curl -L -A "Install Jupyter" | bash.

When you run this script you will have to enter a password that you will use to access jupyter lab. This is hashed before it is stored.

The script should open a web browser to jupyter, but you can also get there by going here for jupyter lab or here for jupyter notebook. I'd go ahead and bookmark that before you forget what port I chose.

The script (jupyter lab version)


You may want to tweak your configuration, and this is easy enough. Just edit the .plist file with open ~/Library/LaunchAgents/com.$(whoami).jupyterlab.plist. This should open it in either TextEdit or LaunchControl if LaunchControl is installed. You can reload the LaunchAgent with launchctl unload ~/Library/LaunchAgents/com.$(whoami).jupyterlab.plist and then launchctl load ~/Library/LaunchAgents/com.$(whoami).jupyterlab.plist. If you are using notebook rather than lab, sub "notebook" for "lab."

Things you might want to change:

Run jupyter instead of jupyter lab

Remove the line <string>lab</string>. I've created a script that does this, as described above.

Change the starting directory

I set the root jupyter directory to my root directory so that I can browse anywhere (jupyter does not let you browse higher than where it is started). You might want to change this. Edit the line <string>--notebook-dir=/</string>, replacing / with your preferred path.

Change the port

Maybe you are already using port 8002 for something else. You can change the port by editing this line <string>8002</string>.


That's it! Hope you find this useful, if you had any issues with the script, please comment and I'll update it.