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
Download the latest Python 3 installer from https://www.python.org/downloads/
Check "Add Python to PATH" and complete installation.
Reopen terminal and verify
python --version
pip -VCreate optional virtual environment
python -m venv .venv
.venv\\Scripts\\activate
pip install --upgrade pipsudo apt update
sudo apt install -y python3 python3-pip python3-venv
python3 --version
pip3 -V
python3 -m venv .venv
source .venv/bin/activatesudo dnf install -y python3 python3-pip
python3 --version
pip3 -V
python3 -m venv .venv
source .venv/bin/activatesudo pacman -S --needed python python-pip
python --version
pip -V
python -m venv .venv
source .venv/bin/activateDependencies (Debian example):
sudo apt update
sudo apt install -y build-essential libssl-dev zlib1g-dev \
libncurses5-dev libffi-dev libbz2-dev libreadline-dev libsqlite3-dev \
liblzma-dev wget curlInstall & configure:
curl https://pyenv.run | bash
echo 'export PYENV_ROOT="$HOME/.pyenv"' >> ~/.bashrc
echo 'command -v pyenv >/dev/null || export PATH="$PYENV_ROOT/bin:$PATH"' >> ~/.bashrc
echo 'eval "$(pyenv init -)"' >> ~/.bashrc
source ~/.bashrc
pyenv install 3.12.4
pyenv global 3.12.4
python --versionDownload from python.org and run, then:
python3 --version
pip3 -Vbrew update
brew install python
python3 --version
pip3 -V✅ Verification
python --version
pip -VIf 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, anotherrequests==2.29).Avoids needing administrator / system-wide installs.
Prevents accidental conflicts with OS packages or other projects.
Makes
requirements.txtreflect 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\\activateInstall dependencies & capture versions:
pip install -r requirements.txt
pip freeze > requirements.txt🔄 Updating
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 .venvLast updated