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