- Install jupyter:
$ pip3 install jupyter
- launch a Jupyter notebook server that is available over the local network:
$ jupyter-notebook --ip=$(hostname -I) --no-browser
$ jupyter-notebook --ip=$(hostname -I) --no-browser
[I 05:51:34.280 NotebookApp] Serving notebooks from local directory: /home/pi
[I 05:51:34.280 NotebookApp] Jupyter Notebook 6.1.5 is running at:
[I 05:51:34.281 NotebookApp] http://192.168.178.108:8888/?token=f217d68ea7f4666a71ec30745f399e2f6c725ef7c7af8895
[I 05:51:34.281 NotebookApp] or http://127.0.0.1:8888/?token=f217d68ea7f4666a71ec30745f399e2f6c725ef7c7af8895
[I 05:51:34.281 NotebookApp] Use Control-C to stop this server and shut down all kernels (twice to skip confirmation).
[C 05:51:34.302 NotebookApp]
To access the notebook, open this file in a browser:
file:///home/pi/.local/share/jupyter/runtime/nbserver-4494-open.html
Or copy and paste one of these URLs:
http://192.168.178.108:8888/?token=f217d68ea7f4666a71ec30745f399e2f6c725ef7c7af8895
or http://127.0.0.1:8888/?token=f217d68ea7f4666a71ec30745f399e2f6c725ef7c7af8895
- Point your web browser to the LAN IP address shown above
Jupyter can have multiple kernels available at any time. Each project can have its own virtual environment. Make sure you have added a pipenv environment ($ pipenv --three|--two
) before attempting this command.
Add a new kernel for the current pipenv using:
$ cd ~/src/path/to/project
$ pipenv run python -m ipykernel install --user --name=$(basename $(pipenv --venv))
Kernels can be added at any time; refresh the jupyter interface if a newly added kernel does not appear.
- Add a pipenv kernel to jupyter:
$ wget https://raw.githubusercontent.com/txoof/develtools/master/pipenv_jupyter.sh
- Start a jupter notebook server:
$ wget https://raw.githubusercontent.com/txoof/develtools/master/jnote_server
Jupyter notebooks can be converted into python using:
$ jupyter-nbconvert --to python notebook.ipynb
NOTE nbconvert will leave notebook magic lines (lines that start with % and !) as well as cell references. Use this template to override this behavior.
Add the template to ~/.jupyter/templates
and run:
$ jupyter-nbconvert --to pytyhon --template python_clean notebook.ipynb