Python Environment Setup


Local Environment Setup

Open a terminal window and type "python" to search out if it is already placed and which version is installed.

  • Unix (Solaris, Linux, FreeBSD, AIX, HP/UX, SunOS, IRIX, etc.)
  • Win 9x/NT/2000
  • Macintosh (Intel, PPC, 68K)
  • OS/2
  • BeOS
  • Amiga
  • VMS/OpenVMS
  • QNX
  • DOS (multiple versions)
  • PalmOS
  • Nokia mobile phones
  • Windows CE
  • Acorn/RISC OS
  • VxWorks
  • Psion
  • Python has also been ported to the Java and .NET virtual machines

Getting Python

The least up-to-date and actual source code, binaries, confirmation, news, etc., is accessible on the official website of Python https://www.python.org/

Users are able to download Python documentation from https://www.python.org/doc/. The tutorials are accessible in HTML, PDF, and PostScript formats.

Installing Python

Python preparation are accessible for various platforms. Users require downloading only the binary code relevant for the platform and installing Python.

If the binary code for the respective platform is not accessible, then you demand a C compiler to compile the source code extremity. Compiling the source code provides much flexibility in terms of selections of features that you necessitate in your installation.

Here is a speedy overview of installing Python on different platforms:

Unix and Linux Installation

  • Here are the easy-to-learn steps provided to install Python on Unix/Linux machines.
  • Open a Web browser and visit thehttps://www.python.org/downloads/
  • Go to the link to download the zipped source code accessible for Unix/Linux.
  • Download & extract files.
  • Editing the Modules/Setup file if users wish to tailor-made some choices.
  • run ./configure script
  • make install

This installation of Python happens at standard location /usr/local/bin and its libraries at /usr/local/lib/pythonXX where XX is the version of Python.

Windows Installation

Here are the various steps to install Python on a Windows machine.

  • Open a Web browser and visithttps://www.python.org/downloads/.
  • Follow the link for the Windows installer python-XYZ.msi file where XYZ is the version you require to install.
  • To utilize this installer python-XYZ.msi, the Windows system needs to render Microsoft Installer 2.0. Save the installer file to use at the local machine. Once you have saved the file, then proceed to run it to discover out whether the machine supports the MSI or not.
  • Run the downloaded file. This will pop up the Python install wizard that is actually easy to exercise. Just evaluate the default settings, wait until the install is accomplished, and you are finished.

Macintosh Installation

Recent Macs launch with Python installed, but it may be various years out of date. See http://www.python.org/download/mac/ for instructions on acquiring the current version along with extra tools to aid development on the Mac. For previous Mac OS's versions such as Mac OS X 10.3 (released in 2003), MacPython is obtainable.

Jack Jansen handles the installation and you could have full access to the whole documentation at his website- http://www.cwi.nl/~jack/macpython. You arise to discover the complete installation items for Mac OS installation.

Setting up PATH

Programs files and other associated executable files could be in numerous directories, so operating systems render a search path that lists the directories that the OS searches for executable.

The path is stored in an environment covariant, which is a personage as a string handled by the OS. This variable compromise of information accessible to the command shell and other programs.

The path changeable is named PATH in Unix or Path in Windows (Unix is case sensitive; Windows is not).

In Mac OS, the installer manages the path facts. To boost the Python interpreter from any special directory, you must line the Python directory to the path.

The setting path at Unix/Linux

To add the Python directory to the path for a significant session in Unix-

  • In the csh shell - type setenv PATH "$PATH:/usr/local/bin/python" and press Enter.
  • In the bash shell (Linux) - type export PATH="$PATH:/usr/local/bin/python" and press Enter.
  • In the sh or ksh shell - type PATH="$PATH:/usr/local/bin/python" and press Enter.
  • Note - /usr/local/bin/python is the path of the Python directory

To add the Python directory to the path for a particular session in Windows -

At the command prompt - type path %path%;C:\Python and press Enter.

Note - C:\Python is the path of the Python directory

Python Environment Variables

Here are crucial environment variables, which can be known by Python


Variable & Description



It has a function akin to PATH. This changeable define the Python interpreter where to locate the module files imported into a program. It should exclude the Python source library directory and the directories incorporating Python source code. PYTHONPATH is erstwhile preset by the Python installer.



It comprises of the path of an initialization file comprising Python source code. It is delivered every time you begin the interpreter. It is named .pythonrc.py in Unix and it includes commands that load utilities or modify PYTHONPATH.



It is utilized in Windows to instruct Python to discover the first case-insensitive match in an import statement. Set this uncertainty to any value to actuate it.



It is an alternate module to find the path. It is normally embedded in the PYTHONSTARTUP or PYTHONPATH directories to sort switching module libraries easily.

Running Python

There are three most important ways to begin Python-

Interactive Interpreter

You can begin Python from Unix, DOS, or any other system that supports you with a command-line interpreter or shell window.

Enter python the command line.

Beginning the coding writing in the interactive interpreter.

$python # Unix/Linux
python% # Unix/Linux
C:> python # Windows/DOS

Here is the list of all the accessible command-line selections-


Option & Description



It offers to debug output.



It constitutes optimized bytecode (resulting in .pyo files).



Do not run import sites to search for Python paths on startup.



verbose output (detailed trace on import statements).



disable class-based built-in exceptions (just use strings); obsolete starting with version 1.6.


-c cmd

run Python script sent in as cmd string



run Python script from given file

Script from the Command-line

A Python script is a significant option to be executed at the command line by including the interpreter on the application, as in the following

$python script.py # Unix/Linux


python% script.py # Unix/Linux


C: >python script.py # Windows/DOS

Note- Be sure the file permission mode authorizes execution.

Integrated Development Environment

You can run Python from a Graphical User Interface (GUI) environment as well if you have a GUI application on your system that supports Python.

  • Unix - IDLE is the very first Unix IDE for Python.
  • Windows - PythonWin is the first Windows interface for Python and is an IDE with a GUI.
  • Macintosh - The Macintosh version of Python along with the IDLE IDE is available from the main website, downloadable as either MacBinary or BinHex'd files.

If you are about to set up the environment decently, then you could take aid from your system admin. Ensure the Python environment is properly set up and executing perfectly fine.

Note - Each example given in the following chapters is executed with Python 2.4.3 version easy to get to on CentOS flavor of Linux.

We already have set up a Python Programming environment online, so that you can execute entire the accessible examples online at the same time when you are educating the theory. Stay on alert to modify any instance and execute it online.

Now, the path is set, we are ready to run python on our local system. Restart CMD, and type python again. It will open the python interpreter shell where we can execute the python statements.

Installation on Mac

To install python3 on macOS, visit the link https://intellinuts.com/python/how-to-install-python-on-mac and follow the instructions given in the tutorial.

Installation on CentOS

To install Python3 on CentOS, visit the link https://intellinuts.com/python/how-to-install-python-3-on-centos and follow the instructions given in the tutorial.

Installation on Ubuntu

To install Python3 on Ubuntu, visit the link https://intellinuts.com/python/how-to-install-python-on-ubuntu and follow the instructions given in the tutorial.

Here at Intellinuts, we have created a complete Python tutorial for Beginners to get started in Python.