Tutorials
Getting Started
01. Setting up your environment
-
Install an IDE. VSCode is a recommended and is popular choice, allowing flexibility with a robust plugin ecosystem.
-
Create a new Python environment. I strongly recommend using Conda or Miniconda for this, but you can also use virtualenv. This will protect our system Python installation from any changes we make.
- If you’re using Conda, you can create a new environment with the following command (with no brackets around the name). You could choose a name like
gisorcdpfor example:conda create -n [pick-a-name] python=3.14 pip
Be sure to replace
[pick-a-name]with a name of your choice for the environment. You can activate the environment (with no brackets around the name) with:conda activate [pick-a-name]It is important to do this step before installing any packages, as it ensures that all packages are installed in the new environment rather than the system Python installation.
- If you’re using Conda, you can create a new environment with the following command (with no brackets around the name). You could choose a name like
-
Install the required packages for the course. You can do this by running the following command in your terminal from the root of the repository:
pip install -r requirements.txt && pip install -e .This is a two-part command (joined together by the
&&). The first part installs all the packages listed in therequirements.txtfile, which includes all the packages we will use in the course. The second part installs the current package in editable mode, allowing you to make changes to the code and have them immediately reflected without reinstalling. This ensures that everyone is using the same versions of the packages, which helps avoid compatibility issues. (This is a primary reason to use a virtual environment, as packages change over time and we want to avoid breaking changes, and your system Python installation remains untouched in case it requires other versions of packages). The second part allows us to continue to add to thecdptoolspackage (in the repo root) as we go through the course, and have those changes immediately available in our environment. We will be adding to thecdptoolspackage throughout the course, and this setup allows us to do that without having to reinstall the package every time we make a change. -
In VSCode, install
Ruff. Ruff is a linter that will help us catch errors in our code and enforce coding standards. It is a fast and efficient linter that works well with Python. You can install it by searching for “Ruff” in the VSCode extensions marketplace. -
In VSCode, install
Black Formatter. Using a consistent formatter will help us keep our code clean and readable and reduce minor changes in our commits. We will useBlackas our default formatter. You can install it by searching for “Black Formatter” in the VSCode extensions marketplace. -
Make sure that your vscode settings are set to use
Blackas the default formatter. You can do this by adding the following lines to yoursettings.jsonfile in the root of the repository (you can access this file by going toCode > Preferences > Settingsand then clicking on the{}icon in the top right corner to open thesettings.jsonfile):"[python]": { "editor.formatOnType": true, "editor.defaultFormatter": "ms-python.black-formatter", "editor.formatOnSave": true }, "[jupyter]": { "editor.defaultFormatter": "ms-python.black-formatter" }, "notebook.lineNumbers": "on", "ruff.importStrategy": "useBundled", "black-formatter.importStrategy": "fromEnvironment", "notebook.formatOnSave.enabled": true, "black-formatter.showNotifications": "always", "notebook.formatOnCellExecution": true, "notebook.diff.ignoreMetadata": true,This will ensure that your code is automatically formatted with
Blackwhen you save it, and thatRuffis used for linting.