Python Installation and Setup
1. Check if Python is Installed
Open your terminal or command prompt and run:
python --version
# or
python3 --version
If you see a version number (e.g., Python 3.11.x), Python is already installed.
2. Installing Python
Windows
- Go to python.org/downloads.
- Download the latest version for Windows.
- Run the installer.
- Crucial Step: Ensure you check the box "Add Python to PATH" at the bottom of the installer window before clicking "Install Now". This allows you to run Python from the command prompt.
macOS
Using Homebrew (Recommended):
brew install python
Using Installer: Download the macOS installer from python.org and follow the prompts.
Linux (Ubuntu/Debian)
Python 3 is usually pre-installed. To install or update:
sudo apt update
sudo apt install python3 python3-pip
3. Package Management (pip)
pip is the standard package manager for Python. It is included by default with Python versions 3.4+.
# Check version
pip --version
# Install a package
pip install requests
4. Virtual Environments
It is best practice to use virtual environments to isolate project dependencies. See the venv module note for details on creating and activating environments.