How to Setup Python Environment

Share on facebook
Share on twitter
Share on pinterest
In this section of the Python tutorial, we will have a look at the Python environment setup on various operating systems including Windows, Linux, Mac OS.

Python Environment Setup

Based on your operating system, hardware architecture, and version of your local machine you can download the latest version of it on its official website.

PythonEnvironment Setup on Windows

Getting Python for Windows

Download Python for Windows from its official website. You can choose between 32-bit (labeled x86) and 64-bit (labeled x86-64) versions on Windows, as well as several installer flavors for each.

The core team of Python feels that there should be a standard that you don’t have to stop and think about, so the yellow download button on the main download page gives you the option of “x86 executable installer.”

This is actually a fine choice: even if you have 64-bit Windows, you don’t need the 64-bit version, the 32-bit Python will work well.

Installing Python on Windows

  • Run the downloaded file.
  • Click on Install Now.
  • After a few mins, it will get installed on your machine.

Setting up PATH on Windows

After installation of Python on your machine, you will require to set up its environment as well.

  • Open Command line:   Start menu -> Run  and type cmd
  • Type:  path %path%;C:\Python
  • Press enter.

Running Python on Windows

  • Open Command line:   Start menu -> Run  and type cmd
  • Type: C:\python27\python.exe

Python Environment Setup on Mac

Getting Python for Mac

Download Python for Mac OS from its official website.  Download the latest version of Python instead of older versions because Apple has now deprecated this.

Installing Python on Mac

Step 1: Install Homebrew (Part 1)

To get started, you first want to install Homebrew:

  1. Open a browser and navigate to After the page has finished loading, select the Homebrew bootstrap code under “Install Homebrew”.
  2. Open a window, paste the Homebrew bootstrap code and then hit Enter.
  3. Confirm the dialog box by clicking on “Install”.

At this point, you’re likely waiting for the command line developer tools to finish installing, and that’s going to take a few minutes. Time to grab a coffee or tea!

Step 2: Install Homebrew (Part 2)

You can keep installing Homebrew and then Python after you have finished installing the Developer Tools command line:

  1. Confirm the “The software was installed” dialog from the developer tools installer.
  2. Press Enter to continue with the Homebrew installation.
  3. Enter your user account password and hit Enter to continue.

Step 3: Install Python

Once Homebrew has finished installing, return to your terminal and run the following command:

$ brew install python3

You can make sure everything went correctly by testing if Python can be accessed from the terminal:

  1. Open the terminal by launching
  2. Type pip3 and hit Enter.
  3. You should see the help text from Python’s “Pip” package manager. If you get an error message running pip3, go through the Python install steps again to make sure you have a working Python installation.

Setting up Python PATH on Mac

The installer configure the path details on Mac.

Running Python on Mac

  • Open Command line:   Finder -> Go menu -> Applications -> Terminal
  • Type: python ~/code/hw01/

Python Environment Setup on Linux

Getting Python for Linux

To install Python 2 and 3 in a Linux environment, install the appropriate packages for your distribution. For Debian and Ubuntu, these packages are pythonpython-devpython3, and python3-dev.

Installing Python on Linux

  • Download and extract files.
  • run ./configure script

After a few mins, it will get installed on your machine.

Setting up Python PATH on Linux

  • The path to adding the Python directory in csh shell is:
type setenv PATH “$PATH: /usr/local/bin/python” and then press Enter.
  • The path to add Python directory in bash shell which is in Linux:
type export PATH = “$PATH: /usr/local/bin/python” and then press Enter
  • The path to add Python directory in sh or ksh shell:
type PATH = “$PATH: /usr/local/bin/python” and then press Enter.

Running Python on Linux

  • Create a folder  ~/pythonpractice, and save your program in that folder.
  • Open up the terminal program. In KDE.
  • Open the main menu and select “Run Command” to open Konsole.
  • Type cd ~/pythonpractice to change directory to your pythonpractice folder, and hit Enter.
  • Type python ./ to run your program!

Subscribe to our Newsletter

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut elit tellus, luctus nec ullamcorper mattis, pulvinar dapibus leo.

Share this post with your friends

Share on facebook
Share on google
Share on twitter
Share on linkedin

Leave a Reply

Your email address will not be published. Required fields are marked *