The files in the /notebooks folder are all interactive files called Jupyter Notebooks. You can read more about them and their uses here.
Some of the Notebooks have a requirement on other Python libraries being installed. It is recommended to use a virtual environment when installing Python dependencies. See working-with-virtual-environments for more information.
- Change into the "/notebooks" directory
- If this is your first time using the notebooks, make a new virtual environment by running
python -m venv .venv. Note: if you have difficulties with this command, check that you are using Python 3.3 or newer. See working-with-virtual-environments for more information. - Activate this new virtual environment by running
source .venv/bin/activate - Install the dependencies for the notebooks by running
pip install -r requirements.txt - Running Python code within this virtual environment will use the dependencies locked within the virtual environment rather than whatever is at the system level.
- To leave the virtual environment type
deactivate.
There are several ways that you can run and use the notebooks. This guide discusses two of them: running in a browser and running inside VSCode. If you have another preferred way of doing this, please add it to the list.
- Change into the "/notebooks" directory.
- Activate the virtual environment by running
source .venv/bin/activate. - Start the Jupyter Notebook server by running
jupyter notebook. - You should now see a browser open with a file listing of the current directory. If you don't see this then open your browser and visit http://localhost:8888/tree.
- Click on a notebook file to open it.
- You can make and save changes to the notebook file and run them to execute code blocks. See the Jupyter docs for more information on what's possible.
- Hit Ctrl-C in the terminal to shutdown the Jupyter server.
IMPORTANT: it is far easier to use the Notebooks inside of VSCode if you open VSCode in the "/notebooks" folder, rather than this top level one. This is so that VSCode will use the Jupyter Notebook specific virtual environment by default. If you discover a way to remove this friction, please let me know!
- Ensure that you have followed the Installing dependencies above.
- Change into the "/notebooks" directory.
- Run VSCode using the
code .command (if you are on OSX you may have to install that command line tool first). - VSCode should automatically pick up the virtual environment and use it as the source of its Python and dependency root folder.
- Jupyter Notebooks in VSCode have pretty much the same user interface as the browser version, so see the Jupyter docs for more information on what's possible.