Back to Chapters
Chapter Progress: 0 %0 / 4 Lessons Read
‹›

1. Introduction to Python

1.2 Installing Python

Highlights & notes

Select lesson text to highlight it, or tap Add note.

    Bookmarks

    Bookmark a lesson to see it here.

      To run Python on your own laptop, install Python 3 from python.org. Then open a terminal (PowerShell on Windows, Terminal on Mac) and check it works:

      • Mac or Linux: python3 --version
      • Windows: py -3 --version
      • You should see something like Python 3.12.4

      A virtual environment is a private toolbox for one project. Packages you install in it don’t clash with your other projects. Create one in your project folder with python3 -m venv .venv (Windows: py -3 -m venv .venv).

      Turn it on with source .venv/bin/activate (Mac or Linux) or .\.venv\Scripts\Activate.ps1 (Windows PowerShell). Run deactivate when you finish.

      Setup in 4 steps

      • Install Python 3 from python.org
      • Check the version in your terminal
      • Create a virtual environment: python3 -m venv .venv
      • Activate it, then run your scripts
      Must Know:

      Create one virtual environment per project. It keeps each project’s packages separate, so upgrading one project never breaks another.

      How it fits together

      1. Install Python 3
      2. Verify in terminal
      3. Create .venv
      4. Run your script

      Step through the code

      Python

      import sysprint(sys.version_info.major)

      Output

      3

      Practice in Python

      In the browser editor, print Python ready. On your computer, check the version in your terminal.

      Expected output
      Python ready

      Reference solution
      print("Python ready")

      Question 1 · Easy

      Which command checks the Python version on Mac or Linux?

      Question 2 · Medium

      What is a virtual environment for?

      Question 3 · Hard

      You activated .venv and installed pandas. In a new terminal window, import pandas fails. Why?

      Key takeaways

      Check your interpreter version and create one virtual environment per project.

      Lesson 2 of 67

      Save your progress

      Start free and your progress, code and notes stay saved. Free for 1 month, no card needed.

      Start free Log in
      PreviousInstalling Python
      Save your progress free for 1 month. Start free · Log in