Create a virtual environment in the current directory and create a Jupyter-lab kernel for that venv. Optionally setup Jupytext to automatically convert Jupyter Lab .ipynb
files into flat python .py
files.
Jupyter Bootstrap should reside in the root of your project. It will create a virtual environment in root of the project folder.
π my_project β project root
ββΒ README.md
ββ requirements.txt
ββΒ π project_files β project files
βΒ Β ββΒ foo.py
βΒ Β ββΒ foo.ipynb
β
ββΒ π jupyter_bootstrap
βΒ Β ββΒ project_init.sh
ββΒ π my_project-VENV-d98f0 β generated virtual environment
Adding jupyter_bootstrap
as a git submodule make it easy to update to the latest version of the script with cd jupyter_bootstrap; git pull
.
Add Jupyter Bootstrap as a git submodule:
cd /src/my_project_root/
git submodule add https://github.com/txoof/jupyter_bootstrap.git
After installing the jupyter_bootstrap
repo run the following command to build a virtual environment and add a jupyter kernel and add the Jupytext module to the system python environment.
From the project root:
./jupyter_bootstrap/project_init.sh -j -t
To take full advantage of Jupyter Lab's file browser and ability to switch kernels, start Jupyter Lab in the directory above your project directory. Open your browser to https://localhost:8888, browse to your project and open a .ipynb
. If you've insalled Jupytext, you can also open .py
files.
π src β start jupyter lab here
ββΒ π my_project
βΒ Β ββΒ π assets
βΒ Β ββΒ π jupyter_bootstrap
βΒ Β ββΒ π my_project-VENV-d98f0
ββΒ π other_project
ββΒ π z_foobar
cd ~/src
jupyter lab
From an open .ipynb
, select the appropriate kernel for this project by clicking in the top right corner of the notebook:
Create a development environment for this project
usage:
$ ./project_init.sh [options]
options:
-c: create the virtual environment
-j: create the virtual environment and add jupyter kernel
-t: install Jupytext and add configuration file for converting .ipynb to .py
-p: purge the virtual environment and clean up kernel specs
--info: virtual environment information
-h: This help screen
- Python 3
- Jupyter Lab installed in your system Python environment
- Git