1 Python
1.1 Virtual Environments
To create a virtual environment in a project folder use:
python3 -m venv .venv-nameTo activate this environment use:
source .venv-name/bin/activateTo deactivate just type:
deactivateOnce in the virtual environment you can install the packages using pip:
pip install numpy jupyterlab ipykernelThese packages are now local to this environment.
To register a specific Jupyter kernel for this project use:
python3 -m ipykernel install --user --name kernel-name --display-name "Python (kernel-name)"You can check registration with:
jupyter kernelspec listIt is recommended to add both a requirements.txt and a .gitignore file incase this folder is stored in Github. To create the requirements.txt file us:
pip freeze > requirements.txtTo create the .gitignore we just use:
touch .gitignoreThen we can open this file and list the .venv folder name.
1.2 Quarto PDF Export
To export using quarto (supposing you have the suitable \(\LaTeX\) packages installed) you first have to add a yaml in a raw block at the top of the page:
---
title: "Data Science Course — Lab 1"
author: "John Robin Inston"
date: today
format:
pdf:
toc: true
number-sections: true
---
You can then render from the terminal with:
quarto render notebook.ipynb --to pdf