Python Environment Setup - Installation and Configuration | W3school

Python is being extensively used in various industries as it a structured and an open-source programming language. Guido Van Rossum created this language in the 1990s and its name was inspired by Monty Python’s Flying Circus program. Companies like NASA, Google etc. are also using python to code their programs and search engines. This dynamic language has a lot of good libraries and object-oriented features for multiple applications in industries. Setting up the Python environment is critical for running Python scripts. Below tutorial will help you in installing Python to be used on your personal computer.

Also Read: Introduction to Python

Getting Python

The latest updated source code, documentation, binaries, news, libraries etc. are available on Python’s official website, The documentation can also be downloaded in multiple formats like PDF, HTML, PostScript etc. from


Installing Python

Python can easily be installed on multiple platforms. Once you have downloaded the binary code compatible with your platform, installing python becomes very straightforward and simple. If you are unable to find a binary code for your platform then you would need a C compiler to install Python by compiling the code manually. The manual compilation will allow you to install only the required features of the Python language.

Linux and Unix Installation

Follow below steps to install Python on a LINUX or UNIX machine

1.      Browse to

2.      Download the latest version of the zipped source code compatible with UNIX/LINUX.

3.      Once downloaded extract the files.

4.      You can edit the Modules/Setup file to customize the Python packages to be installed on your machine.

5.      Run the script ./configure.

6.      Install Python at the standard location /usr/local/bin. The libraries should be installed at /usr/local/lib/pythonXX, where XX represents the python version.

Windows Installation

Follow below steps to install Python on a Windows machine

1.      Browse to

2.      Download the latest version of the zipped source code compatible with Windows machine or download the Windows installer python-XX.msi file where XX represents the python version.

3.      Once downloaded extract the zip files.

4.      You can follow the documentation to install Python from zip files.

5.      If you have downloaded the .msi file then you can directly run it to install Python. Make sure that you have the Microsoft Installer 2.0 version to run the .msi file.

6.      The python wizard comes upon running the .msi file. This interface is very easy and straightforward to use and install Python.


Mac OS X Installation

Generally, Python is pre-installed on all the Mac machines. Make sure to check that the python version installed is the latest. If this is not the case then you can install python by following the documentation from the webpage, If your Mac has an older version of OS X i.e. OS X 10.3 or lesser, then you can install MacPython on your machine.

Setting the Path

The programs and executable files can be stored in multiple directories, hence the operating systems need a search path that lists the folders where the OS can search for executable files to initiate the Python commands. The path is mostly stored in an environment variable. This environment variable stores the information that is available to various programs and the command shell. In UNIX this path variable is called ‘PATH’ and in Windows, it is referred to as ‘Path’. Case sensitivity is important to note here. In MAC, the installer takes care of the path details. To run Python from any working directory, the Python directory must be added to the path.

Setting Path in UNIX/LINUX

Follow below steps to add the Python directory to the PATH in Unix:

1.      In csh shell – execute the command: setenv PATH “$PATH:/usr/local/bin/python”.

2.      In bash shell – execute the command: export PATH=”$PATH:/usr/local/bin/python”.

3.      In ksh or sh shell – execute the command: PATH=”$PATH:/usr/local/bin/python”.

Setting path in Windows

To add the Python directory to the path in Windows execute the command – path %path%;C:\Python in the command prompt.

You can also follow the below steps to set up the path in windows:

1.      Right click on My Computer and browse to Properties ->Advanced System setting ->Environment Variable ->New.

2.      In the variable name enter the path and in the variable value enter the directory link where Python is installed (Default should be: C://Python).

3.      Click Ok ->Ok and the path is now set up in Windows.


Python Environment Variables

Some important environment variables that Python recognizes are:

1.      PYTHONPATH: This variable sore the directory information where Python interpreter can find the module files called by a particular program. It also contains the source library directory and details of the directory having the Python source code. This variable can be preset by the Python installer.

2.      PYTHONSTARTUP: This variable contains the path of the initialization file which has the Python source code. Whenever the interpreter is started this variable is executed. It is called / in Unix and stores the commands that modify PYTHONPATH or load utilities.

3.      PYTHONCASEOK: This variable is utilized as a part of Windows and trains Python to look for a first case-delicate match in the import explanation. Setting it to any esteem enacts this variable.

4.      PYTHONHOME: This variable is generally embedded in PYTHONPATH or PYTHONSTARTUP directories and helps in an easy switching of module libraries. It can be used as an alternative module search path.

Running Python

Python can be started in the system in the following three ways:

1.      Interactive Interpreter: If your operating system supports shell window or command line interpreter then it is simple to start Python. The Python command line can be used directly to execute programs and codes. Some of the command line options are:

a.      –d: This command displays the debug output.

b.      –o: This command can be used to optimize bytecode.

c.       –s: This command stops calling the import site to search for Python paths.

d.      –v: This command will show the detailed trace on import statements.

e.      –x: This disables the class-based built-in exceptions. Not available in versions 1.6 or higher.

f.        –c cmd: Runs the Python script as cmd string.

g.      file: Runs the Python script from a particular file.

2.      A script from the Command-line: Any python program saved in the form pf a scrip file with the extension .py can be executed from the command line by starting the interpreter. Use the following commands:

a.      Unix/Linus: Command – $python or python%; where ‘script’ can be changed to your program filename.

b.      Windows: Command – C: >python; change ‘script’ to the name of the file containing your Python code.

3.      Integrated Development Environment: Python can be run from a GUI (Graphical User Interface) environment as well. You can install any of the below graphical interfaces to run Python in interactive mode:

a.      Unix: IDLE is the most famous GUI IDE for Python.

b.      Windows: PythonWin or Anaconda can be used to run Python in an IDE with GUI.

c.       Mac OSX: The Mac compatible version of Python with IDLE IDE can be downloaded from Python’s website as either BinHex’d files or MacBinary.

If by any chance you are unable to set up the Python environment properly then take help from the system admin. Until and unless the Python environment is set up correctly, the codes won’t execute on your machine.



Python is a user-friendly and a multipurpose language that is compatible with almost all the operating systems. Setting it up is also very simple and pretty straightforward. It’s features like intractability, expandability, portability, and scalability make it very useful to be used in various applications like coding, web designing etc. Many backend web pages are being coded in Python nowadays as well. The above tutorial will get you started on setting up the Python environment on your laptop or desktop. You can follow the above set of instructions and start your coding journey in Python.