Python

Install and manage Python locally (Windows, macOS, Linux) using official installers, system packages, or pyenv; create virtual environments.

🧾 Overview

Python is used for bots, APIs, automation, scripting, and data tasks. Local installation allows you to install dependencies and test before deploying to Discloud.


📥 Installation

1

Download the latest Python 3 installer from https://www.python.org/downloads/

2

Check "Add Python to PATH" and complete installation.

3

Reopen terminal and verify

python --version
pip -V
4

Create optional virtual environment

python -m venv .venv
.venv\\Scripts\\activate
pip install --upgrade pip

✅ Verification

python --version
pip -V

If distro uses python3, substitute accordingly.

If your distribution uses python3 invoke that instead of python.


🗂 Virtual Environments

What it is: A virtual environment is an isolated directory tree containing its own Python interpreter and installed packages, separate from your global (system) Python.

Why use it:

  • Keeps project dependencies isolated (one project can use requests==2.31, another requests==2.29).

  • Avoids needing administrator / system-wide installs.

  • Prevents accidental conflicts with OS packages or other projects.

  • Makes requirements.txt reflect only what the project actually needs (reproducibility when deploying or sharing).

  • Lets you test upgrades safely (create a new env, install, compare behavior).

Create & activate:

python -m venv .venv
source .venv/bin/activate  # Windows: .venv\\Scripts\\activate

Install dependencies & capture versions:

pip install -r requirements.txt
pip freeze > requirements.txt

🔄 Updating

Task
Command

Upgrade pip

python -m pip install --upgrade pip

Upgrade a package

pip install <name> --upgrade

Install new Python (pyenv)

pyenv install <version>


🗃 Common Commands

pip install requests
pip list
pip freeze > requirements.txt
python main.py
python -m venv .venv

Last updated