Install Python and set up a project

3.15.2

Check your Python version, create an isolated environment, and run a script from the terminal.

On this page

Check the interpreter

Use the Python command that resolves to your installation. On Windows with the Python install manager, use py -3.15 to explicitly choose that series. On macOS and Linux, use python3.15 when available, or check the version behind python3 before following version-specific examples.

python --version

Create a virtual environment

A virtual environment gives the project its own installed packages. Run venv in the project folder using the interpreter you intend to use.

python -m venv .venv

Activate on Windows

In PowerShell, run the activation script below. Activation changes command lookup for this shell. You can also run the environment’s Python directly at .venv/Scripts/python.exe.

.venv\Scripts\Activate.ps1

Activate on macOS or Linux

In Bash or Zsh, activate the environment with source. The virtual environment’s Python executable is also available at .venv/bin/python.

source .venv/bin/activate

Run a Python file

Save the code below as hello.py. From its folder, run python hello.py. Use python -m pip to install project packages with the same interpreter you use to run the script.

print("Hello, Python!")
Example output
Hello, Python!

Official references