Permalink
Cannot retrieve contributors at this time
Name already in use
A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
HOWTOs/jupyter-lab-setup.md
Go to fileThis commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
85 lines (64 sloc)
2.02 KB
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
### Installation | |
``` | |
python3 -m venv mypython | |
source mypython/bin/activate | |
pip install --upgrade pip | |
pip install jupiterlab | |
pip install --upgrade webio_jupyter_extension | |
``` | |
### Installation of Kernels | |
For the Julia kernel: | |
``` | |
julia> Pkg.add("IJulia") | |
``` | |
### Configuring | |
Generate a config file in `~/.jupyter` - backup this folder if you have it already. | |
``` | |
jupyter lab --generate-config | |
``` | |
generate a key pair for https protocol | |
``` | |
cd ~/.jupyter | |
openssl req -x509 -nodes -days 3650 -newkey rsa:2048 -keyout mykey.key -out mycert.pem | |
``` | |
suncommented and change lines in my `.jupyter/jupyter_lab_config.py` | |
``` | |
c.ServerApp.allow_origin = '*' | |
c.ServerApp.browser = '' | |
c.ServerApp.certfile = u'/home/USER/.jupyter/mycert.pem' | |
c.ServerApp.disable_check_xsrf = True | |
c.ServerApp.ip = '*' | |
c.ServerApp.keyfile = u'/home/USER/.jupyter/mykey.key' | |
c.ServerApp.open_browser = False | |
c.ServerApp.port = PORT | |
c.ServerApp.token = 'TOKEN' | |
``` | |
To see these lines I used `grep -v "^#" jupyter_lab_config.py |grep "c"`. | |
- `USER` is the username | |
- `PORT` a random port number, e.g. `13267` | |
- `TOKEN` a long random string, e.g. `dsfdsjfjsGDDGFAHj73527466523sjdfgjgfjsgfjsdjjfdgjdfgjdsfkghfkbh` | |
### Startup | |
You may use the following script to startup a jupyter lab session: | |
```bash | |
#!/bin/bash | |
token=$(grep ServerApp.token ~/.jupyter/jupyter_lab_config.py | cut -d ' ' -f 3) | |
token=${token:1:-1} | |
hostname=$(hostname -s) | |
port=$(grep "c.ServerApp.port " ~/.jupyter/jupyter_lab_config.py | cut -d' ' -f3) | |
echo connect to: | |
echo https://${hostname}:${port}/lab?token=$token | |
echo | |
echo | |
jupyter lab --no-browser --LabApp.workspaces_dir=. | |
``` | |
### Using in VS Code | |
To avoid "self-signed certificate" error add the following in VS Code settings `.json` | |
``` | |
"jupyter.allowUnauthorizedRemoteConnection": true, | |
"http.proxyStrictSSL": false, | |
``` | |
and the next in `.bashrc` | |
``` | |
export NODE_TLS_REJECT_UNAUTHORIZED='0' | |
``` | |
Make sure to kill all VS Code servers which may be still running in the background and restart VS Code (cmd+shift+p remote-ssh: kill remote host... ). |