Discussions | Canvas | Repositories | Python Setup |
---|
ℹ️ Course website (this) and GitHub are new and still under construction. Please bear with us and notify us of any issues/suggestions.
This website focuses on the online platforms of this course to help you onboard. Refer to the syllabus, day-1 lecture slides, announcements, etc. on Canvas for complete coverage on everything else.
This website focuses on the online platforms of this course to help you onboard. Refer to the syllabus, day-1 lecture slides, announcements, etc. on Canvas for complete coverage on everything else.
This reference (not a tutorial/guide) is written by a CA who doesn't know everything. Some information can be incomplete, confusing, or just plain wrong, but that's what documentation, Discussions, StackOverflow, etc. is for:)
Necessary XKCD comic
There are many ways to setup a Python environment and dealing with it can be a pain in the ass. Fortunately, this class isn’t too picky beyond having Python 3.9+ with a few dependencies/libraries. If you already have an existing Python setup that you like, you can probably skip to installing dependencies.
We loosely recommend this 3rd-party reference).
An environment encapsulates a set of development tools (e.g. a set of dependencies and even a Python version) that you can use for a project, multiple projects, or all projects across your entire OS. Choose between:
Recommended, also enables using multiple environments.
pyenv
(pyenv-win
for Windows) manages multiple Python versions so you can switch between them for different projects (see pyenv-virtualenv
for also managing environments)conda
manages multiple environments that also each have their own Python version, unlike pyenv
which lets you share a Python version across different environments.Mac preinstalls a system-dependent version of Python in /usr/local/bin/
, but we recommend not touching/breaking that. Windows and Linux do not preinstall their own Python.
pyenv
, conda
, etc. already have their own support for managing Python environments (so skip this if that applies). But if you installed a single Python version via homebrew, python.org, etc., use virtual environments (venv
s).
venv
is built-in with Python and lets you manage multiple environments for dependencies that still share the same global Python that you installed earlier. It requires remembering a few commands to activate/open etc. for a project, but you can automate that or opt for pyenv-virtualenv
, conda
, etc. which do it for you.
Each lab requires the same dependencies, which we listed in the requirements.txt
file of each repo. So if you're using a dedicated environment, you can use the same one for each lab.
For most cases (and once you enter your dedicated environment, if not defaulting to a global one), run pip install -r requirements.txt
at the repo level to install dependencies using the pip
Python package manager. Beware that some previous options recommend a different package manager, e.g. conda install --yes --file requirements.txt
.
Once you clone and open your lab in your favorite IDE, set it up to run Jupyter notebooks. Some popular ones:
ms-toolsai.jupyter
extension, then click Select Kernel
→ Python Environments...
→ Python 3.X /path/to/python
.jupyter lab
in the terminal at the repo level, which opens the IDE (http://localhost:...
)jupyter server --no-browser --NotebookApp.alloworigin="\*"
in the terminal and copy-paste that local server URL into the IDE settings. Follow platform-specific instructions.