In Sep, 2021, Jupyterlab Desktop App (electron) was released by Mehmet Bektas (github repo).
brew install --cask jupyterlab
Choose "Install Python environment using the bundled installer"... and then "Apply and restart"
Tired of opening terminal to launch Jupyterlab, and having to leave it opened all the time? Try to run Jupyterlab as a desktop app:
One of a benefits is avoiding the annoying accident: "closed Jupyterlab when quitting the browser".
brew instal miniconda
Homebrew will install latest version of miniconda, and later you can keep miniconda updated with
brew upgrade miniconda
After installation, you need to run a command to setup conda
conda init "$(basename "${SHELL}")"
conda create -n jupyter python ipython jupyterlab nodejs
conda activate jupyter
You can verify installation with
python --version
node -v
which node
jupyter --version
which jupyter
Test jupyter:
jupyter lab
Run in Terminal
jupyter-lab --generate-config
Edit ~/.jupyter/jupyter_lab_config.py
, and add lines below to the end of the file, or read explanations to decide configuration...
c.LabApp.open_browser = False
c.ServerApp.open_browser = False
c.ServerApp.password_required = False
c.ServerApp.allow_remote_access = False
c.ServerApp.root_dir = '~/'
c.ServerApp.token = ''
Note: I'm using zsh (rather than bash)
#!/bin/zsh
PATH="/opt/homebrew/Caskroom/miniconda/base/bin:$PATH"
eval "$(conda 'shell.zsh' hook)"
conda activate jupyter
cd ~
/opt/homebrew/Caskroom/miniconda/base/envs/jupyter/bin/python -m jupyter lab
I save it as /opt/homebrew/bin/jupyterservice
, and render it executable:
chmod +x /opt/homebrew/bin/jupyterservice
Create a plist file for launchctrl, and save it as ~/Library/LaunchAgents/com.jupyter.lab.plist
:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Label</key>
<string>local.job</string>
<key>ProgramArguments</key>
<array>
<string>/opt/homebrew/bin/jupyterservice</string>
</array>
<key>RunAtLoad</key>
<true/>
<key>StandardErrorPath</key>
<string>/tmp/local.job.err</string>
<key>StandardOutPath</key>
<string>/tmp/local.job.out</string>
</dict>
</plist>
Run in terminal
launchctl load ~/Library/LaunchAgents/com.jupyter.lab.plist
This will launch jupter lab
in background... you can visit jupyter in browser: `http://localhost:8888"
If you want to restart jupyter lab:
Run in Terminal
launchctl unload ~/Library/LaunchAgents/com.jupyter.lab.plist
launchctl load ~/Library/LaunchAgents/com.jupyter.lab.plist
... and here's a handy function you can save in .zshrc
(for bash users: .bashrc
or .bash_profile
), so you can run lctl reload ~/Library/LaunchAgents/com.jupyter.lab.plist
in terminal to reload in a single line, or make it an Alfred workflow:
function lctl {
COMMAND=$1
PLIST_FILE=$2
if [ "$COMMAND" = "reload" ] && [ -n "$PLIST_FILE" ]
then
echo "reloading ${PLIST_FILE}.."
launchctl unload ${PLIST_FILE}
launchctl load ${PLIST_FILE}
else
echo "either command not specified or plist file is not defined"
fi
}
or, you can set up aliases for convenience, save it at the end of .zshrc
:
# for jupyter
alias jpu="launchctl unload ~/Library/LaunchAgents/com.jupyter.lab.plist"
alias jpl="launchctl load ~/Library/LaunchAgents/com.jupyter.lab.plist"
alias jpr="jpu && jpl"
Nativefier github: https://github.com/jiahaog/nativefier
Run in Terminal
# in case you didn't activate virtual environment `jupyter` set as above:
conda activate jupyter
npm install nativefier -g
cd ~/Applications
nativefier "http://localhost:8888"
Adding theme to Jupyter lab:
jupyter labextension install @arbennett/base16-gruvbox-dark
jupyter labextension install @arbennett/base16-gruvbox-light
jupyter labextension install @arbennett/base16-mexico-light
jupyter labextension install @arbennett/base16-monokai
jupyter labextension install @arbennett/base16-nord
jupyter labextension install @arbennett/base16-one-dark
jupyter labextension install @arbennett/base16-outrun
jupyter labextension install @arbennett/base16-solarized-dark
jupyter labextension install @arbennett/base16-solarized-light
jupyter labextension install @arbennett/base16-summerfruit-light
Other useful commands:
jupyter --version
jupyter lab clean
jupyter lab build
https://naysan.ca/2019/09/07/jupyter-notebook-as-a-service-on-ubuntu-18-04-with-python-3/
bash /Download/Anaconda3-2018.12-MacOSX-x86_64.sh
->
bash ./Anaconda3-2018.12-MacOSX-x86_64.sh