Python Tutorial 0/52 lessons ~6 min read Lesson 3

    Installing Python

    Install Python 3.11+ from python.org, or via pyenv (recommended for multi-version) or your OS package manager.

    Course progress0%
    Focus
    9 guided sections
    Practice signal
    Examples included
    Career prep
    Interview Q&A included

    Introduction

    Install Python 3.11+ from python.org, or via pyenv (recommended for multi-version) or your OS package manager. Pair it with a virtual environment tool from day one.

    Understanding the topic

    Core concepts to understand:

    • Use pyenv to manage multiple Python versions.
    • python -m venv .venv creates an isolated env.
    • Activate per shell: source .venv/bin/activate.
    • Verify: python --version.

    Syntax reference

    Visual flow / code:

    bash
    # macOS / Linux
    brew install pyenv
    pyenv install 3.12.0
    pyenv global 3.12.0
    # Create project venv
    python -m venv .venv
    source .venv/bin/activate
    pip install --upgrade pip

    Execution workflow

    1Installing Python Workflow
    1 / 4

    Use pyenv to manage multiple…

    Use pyenv to manage multiple Python versions.

    Real-world use

    Every serious Python project ships with its own venv (or Poetry/uv). Never install packages globally on a dev machine — you'll regret it.

    Best practices

    • Always work inside a venv.
    • Pin Python version with .python-version.
    • Use uv or poetry for modern projects.

    Common mistakes

    • Mixing system Python with project deps causes breakage.

    Advanced interview questions

    Interview Prep

    Practice concise answers, then expand each card for the explanation.

    3 questions
    1BeginnerQuestionWhy use a virtual environment?+

    Answer

    A virtual environment gives each project its own interpreter link and site-packages directory, so dependencies and their versions do not collide between projects or with the system Python. It also lets you install packages without admin rights and recreate the environment from a requirements or lock file. You create one with python -m venv .venv and activate it before installing.

    Follow-up

    What does activating a venv actually change?
    2IntermediateQuestionPyenv vs conda vs venv?+

    Answer

    venv is in the standard library and only isolates packages for a Python version you already have installed. pyenv builds and switches between multiple Python versions on Unix-like systems but does not manage packages by itself. conda is a separate package and environment manager that can install Python itself plus non-Python binary dependencies, which is useful in scientific work.

    Follow-up

    When would you pick conda over venv plus pip?
    3IntermediateQuestionHow do you pin Python version?+

    Answer

    Pin it at several levels: set requires-python in pyproject.toml to declare supported versions, add a .python-version file for pyenv or uv to select the interpreter locally, and run CI and Docker images on an exact version tag. A tool such as uv or pyenv can then install that version. requires-python is only a constraint check for installers, not something that installs Python for you.

    Follow-up

    How does requires-python affect pip when a package does not support your version?

    Summary

    In summary: Install 3.11+. One venv per project — no exceptions.

    Ready to mark this lesson complete?Track your journey across the entire course.