Python Setup Guide
Python Setup Guide
Section titled “Python Setup Guide”Installing Python is only the first step. A usable development setup also needs environment isolation, predictable package installation, and a repeatable workflow.
1. Create a Project Folder
Section titled “1. Create a Project Folder”mkdir my-python-projectcd my-python-project2. Create a Virtual Environment
Section titled “2. Create a Virtual Environment”python -m venv .venvUsing a project-local virtual environment keeps dependencies isolated and avoids contaminating the global interpreter.
3. Activate the Environment
Section titled “3. Activate the Environment”Windows PowerShell
Section titled “Windows PowerShell”.venv\Scripts\Activate.ps1Windows Command Prompt
Section titled “Windows Command Prompt”.venv\Scripts\activatemacOS or Linux
Section titled “macOS or Linux”source .venv/bin/activate4. Upgrade the Packaging Tools
Section titled “4. Upgrade the Packaging Tools”python -m pip install --upgrade pip setuptools wheel5. Install Packages
Section titled “5. Install Packages”python -m pip install requestsList installed packages:
python -m pip list6. Keep Dependencies Explicit
Section titled “6. Keep Dependencies Explicit”For simple projects:
python -m pip freeze > requirements.txtThat is not the only packaging strategy, but it is a workable starting point for smaller repos and tutorials.
7. Run a Sanity Check Script
Section titled “7. Run a Sanity Check Script”import requests
print("Environment is ready")When a Custom Package Repository Matters
Section titled “When a Custom Package Repository Matters”If you work inside an enterprise environment, your team may use an internal mirror or repository manager. In that case:
- follow your team’s package index rules
- configure the index URL intentionally
- document the expected setup inside the project README
Good Defaults for Everyday Python Work
Section titled “Good Defaults for Everyday Python Work”- use one virtual environment per project
- prefer
python -m pipover barepip - keep secrets out of source control
- use formatting and linting early, not only at the end