Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
350 changes: 347 additions & 3 deletions Basics.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -2916,13 +2916,357 @@
},
{
"cell_type": "markdown",
"id": "3ebab575",
"id": "fb1b118c",
"metadata": {
"editable": false
},
"source": [
"<!-- #endsolution -->"
"# <ins>**Appendix: Running python locally**</ins>"
]
},
{
"cell_type": "markdown",
"id": "d029a1c0",
"metadata": {
"editable": false
},
"source": [
"To run python outside of the JupyterLite environment you need to install it locally. As with a lot of large programming languages there are multiple solutions to do this. The two common families of solutions are python with pip and conda/mamba."
]
},
{
"cell_type": "markdown",
"id": "e8556ab8",
"metadata": {
"editable": false
},
"source": [
"| Feature | **Python with pip** | **Conda/Mamba** |\n",
"|---------|----------------|-----------------|\n",
"| **Installation** | Install Python from python.org, pip included | Install Anaconda/Miniconda distribution |\n",
"| **Package Management** | `pip install package` | `conda install package` or `mamba install package` |\n",
"| **Environment Management** | `venv` or `virtualenv` (separate tools) | Built-in: `conda create -n myenv` |\n",
"| **Package Repository** | PyPI (Python Package Index) | Anaconda repository + conda-forge |\n",
"| **Non-Python Dependencies** | Limited (Python packages only) | Excellent (handles Python, R, C libraries, etc.) |\n",
"| **Complexity** | Simpler, more lightweight | More comprehensive, heavier |\n",
"| **Best For** | Pure Python development, simple projects | Data science, scientific computing, complex dependencies |\n",
"| **Speed** | Fast package installation | Slower (conda), faster with mamba |\n",
"| **Architecture Support** | Excellent (source packages work on any architecture, if compiling tools available) | Limited to pre-built binaries for common architectures |\n",
"| **Reproducibility** | `requirements.txt` | `environment.yml` with exact versions |\n",
"| **Modern Tooling** | **uv** (ultra-fast installer), **Poetry** (dependency & packaging) | **Mamba** (faster conda drop-in replacement), **Pixi** (modern project/workflow tool) |"
]
},
{
"cell_type": "markdown",
"id": "9bf355f1",
"metadata": {
"editable": false
},
"source": [
"### Installing Python and pip"
]
},
{
"cell_type": "markdown",
"id": "d0b30d43",
"metadata": {
"editable": false
},
"source": [
"#### On Windows:"
]
},
{
"cell_type": "markdown",
"id": "e0a9656c",
"metadata": {
"editable": false
},
"source": [
"1. Go to https://www.python.org/downloads/) and choose the latest stable installer for Windows (for example, \u201cWindows installer (64-bit)\u201d).\n",
"2. During installation, make sure to check the box \u201cAdd Python to PATH\u201d so you can use Python from any command prompt.\n",
"3. After installation finishes, open a new Terminal (Command Prompt or PowerShell) and type:\n",
"\n",
"```python\n",
"python --version\n",
"```\n",
"\n",
"This should confirm that Python installed successfully.\n",
"\n",
" - Alternatively, you could install the Anaconda distribution from https://www.anaconda.com/products/distribution, which includes Python and a variety of data-science packages by default."
]
},
{
"cell_type": "markdown",
"id": "b03e4874",
"metadata": {
"editable": false
},
"source": [
"#### On Linux (Ubuntu/Debian-based):"
]
},
{
"cell_type": "markdown",
"id": "546d664c",
"metadata": {
"editable": false
},
"source": [
"1. Open a terminal.\n",
"2. Run:\n",
"```\n",
"sudo apt-get update\n",
"sudo apt-get install python3 python3-pip\n",
"```\n",
"(Adjust to python or python3 depending on your distribution)\n",
"\n",
"3. Confirm your installation by running:\n",
"```python\n",
"python3 --version\n",
"```\n",
"\n",
" - For Fedora or other distributions, replace `apt-get` with `yum`, `dnf`, or your distro\u2019s package manager.\n",
" - You can also install Anaconda if you want a more complete environment."
]
},
{
"cell_type": "markdown",
"id": "d25e9eaa",
"metadata": {
"editable": false
},
"source": [
"#### On macOS:"
]
},
{
"cell_type": "markdown",
"id": "32384276",
"metadata": {
"editable": false
},
"source": [
"1. Visit https://www.python.org/downloads/ and download the macOS installer (e.g., \u201cmacOS 64-bit universal2 installer\u201d).\n",
"2. Double-click the `.pkg` file and follow the prompts.\n",
"3. After installation, open Terminal and check:\n",
"```\n",
"python3 --version\n",
"```\n",
"\n",
" - Alternatively, on macOS you can install Python via Homebrew (if you already have Homebrew installed) by running:\n",
"```\n",
"brew install python3\n",
"```"
]
},
{
"cell_type": "markdown",
"id": "6ad36f9c",
"metadata": {
"editable": false
},
"source": [
"#### Installing and Running Jupyter Notebooks"
]
},
{
"cell_type": "markdown",
"id": "88323ba7",
"metadata": {
"editable": false
},
"source": [
"1. Once Python is installed (whether from python.org, your Linux package manager, or Anaconda), you can install Jupyter Lab as follows:\n",
"```\n",
"pip install jupyterlab\n",
"```\n",
"(Use `pip3` if needed, e.g., \u203a `pip3 install jupyter`)\n",
"\n",
"2. When everything is installed, you can start a Jupyter notebook server (or Jupyter Lab) and work on your Python exercises by simply running in your terminal or command prompt:\n",
"```\n",
"jupyter notebook\n",
"```\n",
"or\n",
"```\n",
"jupyter lab\n",
"```\n",
"\n",
"This will open a new tab in your web browser with the Jupyter Notebook or Jupyter Lab interface, ready for you to start coding!"
]
},
{
"cell_type": "markdown",
"id": "1ea7de96",
"metadata": {
"editable": false
},
"source": [
"### Installing Mamba (via Miniforge)"
]
},
{
"cell_type": "markdown",
"id": "88f8fa02",
"metadata": {
"editable": false
},
"source": [
"#### On Windows:"
]
},
{
"cell_type": "markdown",
"id": "bc5d5add",
"metadata": {
"editable": false
},
"source": [
"1. Go to https://github.com/conda-forge/miniforge and download the Miniforge3 installer for Windows (e.g., \"Miniforge3-Windows-x86_64.exe\").\n",
"2. Run the installer and follow the prompts. You can accept the default options.\n",
"3. After installation, open \"Miniforge Prompt\" from the Start menu and verify:\n",
"\n",
"```bash\n",
"mamba --version\n",
"conda --version\n",
"```\n",
"\n",
"This should confirm that Mamba and Conda are installed successfully.\n",
"\n",
" - Miniforge comes with `mamba` pre-installed and uses conda-forge as the default channel."
]
},
{
"cell_type": "markdown",
"id": "a9daafa9",
"metadata": {
"editable": false
},
"source": [
"#### On Linux (Ubuntu/Debian-based and others):"
]
},
{
"cell_type": "markdown",
"id": "ba271553",
"metadata": {
"editable": false
},
"source": [
"1. Open a terminal and download the installer:\n",
"```bash\n",
"wget https://github.com/conda-forge/miniforge/releases/latest/download/Miniforge3-Linux-x86_64.sh\n",
"```\n",
"\n",
"2. Run the installer:\n",
"```bash\n",
"bash Miniforge3-Linux-x86_64.sh\n",
"```\n",
"\n",
"3. Follow the prompts, accept the license, and allow the installer to initialize Miniforge.\n",
"\n",
"4. Restart your terminal or run:\n",
"```bash\n",
"source ~/.bashrc\n",
"```\n",
"\n",
"5. Confirm your installation:\n",
"```bash\n",
"mamba --version\n",
"conda --version\n",
"```\n",
"\n",
" - For ARM-based systems, download `Miniforge3-Linux-aarch64.sh` instead."
]
},
{
"cell_type": "markdown",
"id": "f2e714e4",
"metadata": {
"editable": false
},
"source": [
"#### On macOS:"
]
},
{
"cell_type": "markdown",
"id": "232aee40",
"metadata": {
"editable": false
},
"source": [
"1. Download the installer from https://github.com/conda-forge/miniforge:\n",
" - For Intel Macs: `Miniforge3-MacOSX-x86_64.sh`\n",
" - For Apple Silicon (M1/M2/M3): `Miniforge3-MacOSX-arm64.sh`\n",
"\n",
"2. Open Terminal and navigate to your Downloads folder, then run:\n",
"```bash\n",
"bash Miniforge3-MacOSX-*.sh\n",
"```\n",
"(Replace `*` with `x86_64` or `arm64` depending on your system)\n",
"\n",
"3. Follow the installation prompts and allow the installer to initialize Miniforge.\n",
"\n",
"4. Restart your terminal or run:\n",
"```bash\n",
"source ~/.bash_profile # or ~/.zshrc if using zsh\n",
"```\n",
"\n",
"5. Verify the installation:\n",
"```bash\n",
"mamba --version\n",
"conda --version\n",
"```\n",
"\n",
" - Alternatively, if you have Homebrew installed, you can run:\n",
"```bash\n",
"brew install --cask miniforge\n",
"```"
]
},
{
"cell_type": "markdown",
"id": "68d32a65",
"metadata": {
"editable": false
},
"source": [
"#### Installing and Running Jupyter Notebooks with Mamba"
]
},
{
"cell_type": "markdown",
"id": "38068a3a",
"metadata": {
"editable": false
},
"source": [
"1. Once Miniforge/Mamba is installed, you can install JupyterLab in a new environment for your project:\n",
"```bash\n",
"mamba create -n myproject python=3.11 jupyterlab\n",
"mamba activate myproject\n",
"```\n",
"\n",
"2. Start Jupyter:\n",
"```bash\n",
"jupyter notebook\n",
"```\n",
"or\n",
"```bash\n",
"jupyter lab\n",
"```\n",
"\n",
"This will open a new tab in your web browser with the Jupyter interface, ready for you to start coding!"
]
},
{
"cell_type": "markdown",
"id": "ac3d4b98",
"metadata": {
"editable": false
},
"source": []
}
],
"metadata": {
Expand All @@ -2941,7 +3285,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.12.3"
"version": "3.13.0"
}
},
"nbformat": 4,
Expand Down
Loading