{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# Installing Python on your computer"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
" This chapter contains some instructions about how to install Python on your personal computer.\n",
"\n",
"There are many ways to install Python on your computer (and while most of them work, some of them are less practical than others for scientific applications). Unless you know what you are doing (i.e.: you have been doing this before), please follow these instructions exactly.\n",
"\n",
"\n",
"```{admonition} Important! What to do if you **already** have python installed on your laptop \n",
":class: warning, dropdown\n",
" \n",
"**If you already have anaconda / conda / miniconda installed**:\n",
"\n",
"You can keep your installation if it works for you and if you know what you are doing. If you are not totally sure, it is recommended to start with a clean installation. To start from scratch, uninstall anaconda and follow the instructions below. \n",
"\n",
"---\n",
"\n",
"**If you don't know what I'm talking about:** \n",
"\n",
"Then you should definitely follow the instructions below.\n",
"```"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"```{admonition} Important! For Windows 7 users\n",
":class: warning, dropdown\n",
"\n",
"Windows 7 is [not supported since January 2020](https://en.wikipedia.org/wiki/Windows_7). It seems that you cannot install `mambaforge` on Windows 7. Regardless of Python, I strongly recommend to update to a version with security updates. \n",
"```"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"To install Python on the computers in the computer lab follow the instructions for a Linux installation. But first you need to apply for a Linux account if you have not done so already. The account will be active the following work day."
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Install Miniconda "
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### On Windows \n",
"\n",
"Go to the miniforge download website: https://github.com/conda-forge/miniforge#mambaforge\n",
"\n",
"Download the **Miniforge** installers for Windows.\n",
"Unless you have an uncommon architecture (unlikely), you should choose the `x86_64` files.\n",
"\n",
" \n",
"\n",
"Double-click the `.exe` file.\n",
"\n",
"Follow the instructions on the screen.\n",
"\n",
"If you are unsure about any setting, accept the defaults. You can change them later. At this stage, I recommend:\n",
"\n",
"\n",
"\n",
"### On Mac OS and Linux\n",
"\n",
"For these platforms, no need to download the files yourself. Open a terminal and do:\n",
"\n",
"```none\n",
"curl -L -O \"https://github.com/conda-forge/miniforge/releases/latest/download/Miniforge3-$(uname)-$(uname -m).sh\"\n",
"bash Miniforge3-$(uname)-$(uname -m).sh\n",
"```\n",
"\n",
"or, if this doesn't work:\n",
"\n",
"```none\n",
"wget \"https://github.com/conda-forge/miniforge/releases/latest/download/Miniforge3-$(uname)-$(uname -m).sh\"\n",
"bash Miniforge3-$(uname)-$(uname -m).sh\n",
"```\n",
"\n",
"The first command downloads the tool, and the second installs it. Follow the prompts on the installer screens.\n",
"\n",
"If you are unsure about any setting, accept the defaults **except for the last question asking you if you wish to run `conda init`: here, answer \"yes\".**\n",
"\n",
"To make the changes take effect, close and then re-open your terminal window.\n",
"\n",
"### Testing your installation\n",
"\n",
"\n",
"To see if everything worked well, open a terminal (Mac and Linux). On Windows, open the `miniforge prompt` (from the Start menu, search for and open \"miniforge prompt\"):\n",
"\n",
" \n",
"\n",
"and type in:\n",
"\n",
"```none\n",
"mamba list\n",
"``` \n",
"\n",
"You should see a long list of package names.\n",
"\n",
"If you type:\n",
"\n",
"```none\n",
"python\n",
"```\n",
"\n",
"A new Python prompt should appear, with something like:\n",
"\n",
"```none\n",
"Python 3.12.5 | packaged by conda-forge | (main, Aug 8 2024, 18:24:51) [MSC v.1940 64 bit (AMD64)] on win32\n",
"Type \"help\", \"copyright\", \"credits\" or \"license\" for more information.\n",
">>>\n",
"```\n",
"\n",
"You can type ``exit()`` to get out of the Python interpreter.\n",
"\n",
"\n",
"```{admonition} Optional: conda, mamba, conda-forge?\n",
":class: note, dropdown\n",
"\n",
"Although the instructions above should work in almost all situations and should get you ready for the class,\n",
"I should explain what we have just done in case you are interested:\n",
"\n",
"We have just installed [miniconda](https://docs.conda.io/en/latest/miniconda.html) which is a minimal installer for the larger project Anaconda. Anaconda is a scientific Python installation which, in my opinion, has too many options and tools that you won't need.\n",
"\n",
"**But** we have not only installed `miniconda`: we have also set some options per default automatically:\n",
"- we now use [conda-forge](https://conda-forge.org/) as default channels to download the Python packages we will use later in the lecture (instead of Anaconda channels).\n",
"- we now use [mamba](https://mamba.readthedocs.io) as the default Python package install tool (instead of `conda`). `mamba install` behaves exactly like `conda install`, but is significantly faster.\n",
"```"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## What is this Python \"interpreter\"? "
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Start with reading the definition from the Tech Terms Dictionary.\n",
"\n",
"Put simply, the Python interpreter is a program executing Python programs or commands. It reads the programs you write and executes the instructions they contain. We will look into interpreters in a little more detail later in the semester, when we will talk about compiled and interpreted languages. "
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## What is a \"Python installation\"?"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"[Explanation for Windows users](02a-Details-Windows)\n",
": the difference between the command prompt, the miniforge prompt, and the Python interpreter\n",
"\n",
"[Explanation for Linux/macOS users](02b-Details-Linux)\n",
": what did ``mambaforge`` do to your terminal?"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Learning checklist\n",
"\n",
"\n",
" \n",
" \n",
" "
]
}
],
"metadata": {
"hide_input": false,
"kernelspec": {
"display_name": "Python 3 (ipykernel)",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.12.5"
},
"toc": {
"base_numbering": 2,
"nav_menu": {},
"number_sections": true,
"sideBar": true,
"skip_h1_title": false,
"title_cell": "Table of Contents",
"title_sidebar": "Contents",
"toc_cell": true,
"toc_position": {},
"toc_section_display": "block",
"toc_window_display": true
}
},
"nbformat": 4,
"nbformat_minor": 4
}