Installation & Setup
Get Python installed on your machine, configure your development environment, and write your first script.
Installing Python
Python is available for all major operating systems. Download the latest version from python.org.
Windows
Download the Installer
Go to
python.org/downloadsand download the latest Python 3.x installer for Windows.Run the Installer
Important: Check the box that says "Add Python to PATH" before clicking "Install Now."
Verify Installation
Open Command Prompt and type:
python --version # Output: Python 3.12.x pip --version # Output: pip 24.x from ...
macOS
# Using Homebrew (recommended) brew install python # Verify python3 --version pip3 --version
Linux (Ubuntu/Debian)
# Update and install sudo apt update sudo apt install python3 python3-pip python3-venv # Verify python3 --version pip3 --version
Setting Up PATH
python in the terminal, the OS looks through PATH directories to find the Python executable.If you forgot to check "Add to PATH" during Windows installation, you can add it manually via System Properties → Environment Variables → Edit PATH → add the Python installation directory (e.g., C:\Python312\ and C:\Python312\Scripts\).
pip Package Manager
pip is Python's package installer. It comes bundled with Python 3.4+ and lets you install third-party libraries from PyPI.
# Install a package pip install requests # Install a specific version pip install requests==2.31.0 # Upgrade a package pip install --upgrade requests # List installed packages pip list # Uninstall a package pip uninstall requests # Generate requirements file pip freeze > requirements.txt # Install from requirements file pip install -r requirements.txt
Virtual Environments
Virtual environments create isolated Python environments for each project, preventing dependency conflicts between projects.
# Create a virtual environment python3 -m venv myproject_env # Activate it (macOS/Linux) source myproject_env/bin/activate # Activate it (Windows) myproject_env\Scripts\activate # Your prompt changes to show the env name (myproject_env) $ pip install requests # Deactivate when done deactivate
IDEs and Editors
| IDE/Editor | Best For | Key Features |
|---|---|---|
| VS Code | General-purpose development | Free, extensions, integrated terminal, Git, Python extension |
| PyCharm | Professional Python development | Intelligent code completion, debugger, testing, Community (free) & Pro editions |
| Jupyter Notebook | Data science & exploration | Interactive cells, inline visualization, markdown support |
| Sublime Text | Lightweight editing | Fast, minimal, extensible, multi-cursor editing |
Running Python Scripts
Create a file called hello.py with any text editor:
# My first Python script name = input("What is your name? ") print(f"Hello, {name}! Welcome to Python.")
Run it from the terminal:
python3 hello.py # What is your name? Alice # Hello, Alice! Welcome to Python.
Python Version Management (pyenv)
If you need to work with multiple Python versions, pyenv lets you install and switch between them easily:
# Install pyenv (macOS/Linux) curl https://pyenv.run | bash # Install a specific Python version pyenv install 3.12.0 pyenv install 3.11.6 # Set global default pyenv global 3.12.0 # Set local version for a project cd myproject pyenv local 3.11.6
Lilly Tech Systems