Python – Installation and Setup

Introduction

Python is open-source and is available to all platforms including Windows, Linux, and Mac OS. Here, first we will check whether python is already installed and then we will learn to setup python in our system.

To check if python is already installed and what version is installed,

  • For Windows pc, open the command line (cmd.exe) and type the below line:

C: \ Users \ Your Name > python –version

  • For Linux or MAC, open command line in Linux and open Terminal in MAC and type below line:

python –version

Python Installation

  • You can download python from https://www.python.org/downloads/
  • Download and extract the file. The file will be downloaded in zipped format.
  • Run the extracted file and accept the default settings if you don’t want to customize it.
  • Wait the installation to complete and you are done.

Environment Path Setup

As UNIX is case sensitive path variable is type in uppercase (PATH) whereas, in windows it is typed as Path. In MAC we don’t have to consider the path details as it is handled by the installer.

Setting path at LINUX/UNIX: To add Python Directory (/user/local/bin/python”) to the path type following and press enter.

  • csh shell – type setenv PATH “$PATH: /user/local/bin/python”.
  • bash shell (Linux) – type export PATH=”“$PATH: /user/local/bin/python”.
  • sh or ksh shell – type export PATH=”“$PATH:/user/local/bin/python”.

Setting path at Windows: C:\Python is path to python directory.

  • Command prompt: type path %path%; C:\Python .

 

Run Python

To run python on your system there are three ways.

  • Interactive interpreter: From command-line interpreter or shell window you can run your python file.

Example, Linux/Unix – $python or %python

Windows/DOS – C:/…….>python

  • Script from command-line: Python script can be executed from command line.

Example, Linux/Unix – $python script.py or python% script.py

Windows – C:\ ….. > python script.py

  • Integrated Development Environment (IDE): If you have a GUI application installed in your system, you can run your python programme from GUI. For Windows, you can use VS Code, PyCharm or any other IDE.

Leave a comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.