Python Environment Setup



Python is available on different platforms, including Windows, Linux, Mac Os. Let's see how to set up a Python environment. In this tutorial, we will work with Python version 3.


Python Installation Verification

Many PCs and Macs will have Python 3 already installed.

To verify if you already have Python 3 installed on a Windows PC, Linux, Mac, open the command line or the terminal and type the following command:

$ python3 --version 
3.8.8 

If you find that you do not have Python 3 installed on your computer, follow the section below to install it for your corresponding operating system.


Install Python

If you find that you do not have Python 3 installed on your computer, follow the sections below to install it for your corresponding operating system.


Install Python on Windows

To install Python on Windows, follow the below steps:

  • Download Python for Windows from the website https://www.python.org/downloads/windows/.
  • Click on the "Latest Python 3 Release - Python X.X.X" link.
  • If your computer is running a 64-bit version of Windows, download the Windows x-86-64 executable installer. Otherwise, download the Windows x86 executable installer.
  • After downloading the installer, you can run it by double click on it and follow the instructions there.

One thing that you should watch out for during the installation is to make sure you tick the "Add Python 3.X to PATH".

Note: If you are using Windows and you get an error message that said "python3 wasn't found", try using python (without 3).


Install Python on Mac OS X

To install Python on Mac Os, follow the below steps:

  • Download the latest Python installer from the website https://www.python.org/downloads/mac-osx/.
  • Download to Mac OS X 64-bit/32-bit installer file.
  • Double click python-3.8.8-macosx10.9.pkg to run the installer.

Install Python on Linux

It is very likely that you already have python installed out of the box. If you have a different version of python installed, at least 3.6, then you don't need to upgrade.

If you don't have Python installed, or if you want a different version, the first thing that you need to do is to check what Linux distribution you are using with the following command:

$ grep  '^NAME='  /etc/os-release 

After running the above command, depending on the result, follow one of the above installation guides.

Install Python on Debian or Ubuntu

If you are using Ubuntu 16.10 or a newer version, you can easily install Python 3.6 with the following commands:

$ sudo apt-get update 
$ sudo apt-get install python3.6

If you want to use a more current Python version, it is recommended to use the deadsnakes PPA to install Python 3.8 or 3.9:

$ sudo apt-get install software-properties-common
$ sudo add-apt-repository ppa:deadsnakes/ppa
$ sudo apt-get update
$ sudo apt-get install python3.8

Install Python on Fedora

To install Python on Fedora distribution, run the following command:

$ sudo dnf install python3

If you are using an old version of Fedora distribution, you might get an error that the command dnf is not found. In this situation, you can use the yum command instead.

Install Python on openSUSE

To install Python on openSUSE distribution, run the following command:

$ sudo zypper install python3


ExpectoCode is optimized for learning. Tutorials and examples are constantly reviewed to avoid errors, but we cannot warrant full correctness of all content. While using this site, you agree to have read and accepted our terms of use, cookie and privacy policy.
Copyright 2020-2021 by ExpectoCode. All Rights Reserved.