Installing Python

From OpenCourse
Revision as of 00:30, 31 July 2023 by OpenCourse (talk | contribs) (Created page with "== Installation == === Linux and MacOS === On Linux and MacOS systems, Python should already be installed. You can verify this using the method in the ''''Checking installation'''<nowiki/>' chapter. If installed, you can skip to the ''''Project setup'''<nowiki/>' chapter. === Installing on Linux === If not installed, simply use your package manager to install ''''python3'.''' ==== Arch ==== On Arch-based distros (e.g. Manjaro), run the following command: sudo pacma...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

Installation

Linux and MacOS

On Linux and MacOS systems, Python should already be installed.

You can verify this using the method in the 'Checking installation' chapter.

If installed, you can skip to the 'Project setup' chapter.

Installing on Linux

If not installed, simply use your package manager to install 'python3'.

Arch

On Arch-based distros (e.g. Manjaro), run the following command:

sudo pacman -Sy python3

Debian

On Debian-based distros (such as Ubuntu), type:

sudo apt install python3

Installing on Windows

On Windows, navigate to the Python website (python.org) and install the latest stable build.

Scroll to the bottom of this page and find 'Windows installer (64-bit)'.

Open the .exe file and go through the installation process.

Note: Make sure to 'add Python to system PATH'. This allows us to use Python through the terminal.

Checking installation

Terminal setup

Once you have installed Python, open a system terminal.

On Linux and MacOS, this is called the 'terminal'.

On Windows, this is called the 'command prompt' or 'powershell'.

Checking Python version

Now we need to run a command to check if Python is installed.

The result should be the name of the Python version you installed, printed to the screen.

Linux or MacOS

On Linux or MacOS, type the following command to check if Python is installed:

python3 --version

Windows

On Windows, type this command into the command prompt:

py --version

Checking Python install

If this returns a Python version, such as below, you have successfully installed Python:

> python3 --version
  Python 3.11.3

However, if this returns an error, like below, try reinstalling Python:

> python3 --version
  zsh: command not found: python3