Environment Setup

First step in the journey of learning Python is to install it on your machine. Today most computer machines, especially having Linux OS, have Python pre-installed. However, it may not be the latest version.

Python is available on a wide variety of platforms including Linux and Mac OS X. Let’s understand how to set up our Python environment.

  • Unix (Solaris, Linux, FreeBSD, AIX, HP/UX, SunOS, IRIX, etc.)
  • Win 9x/NT/2000
  • Macintosh (Intel, PPC, 68K)
  • OS/2
  • DOS (multiple versions)
  • PalmOS
  • Nokia mobile phones
  • Windows CE
  • Acorn/RISC OS
  • BeOS
  • Amiga
  • VMS/OpenVMS
  • QNX
  • VxWorks
  • Psion

Python has also been ported to the Java and .NET virtual machines

Local Environment Setup

Open a terminal window and type “python” to find out if it is already installed and which version is installed. If Python is already installed then you will get a message something like as follows:

$ python
Python 3.11.2 (main, Feb 8 2023, 14:49:24) [GCC 9.4.0] on linux
Type "help", "copyright", "credits" or "license" for more information.

>>>
Downloading Python
The most up-to-date and current source code, binaries, documentation, news, etc., is available on the official website of Python https://www.python.org/

You can download Python documentation from https://www.python.org/doc/. The documentation is available in HTML, PDF, and PostScript formats.

Installing Python
Python distribution is available for a wide variety of platforms. You need to download only the binary code applicable for your platform and install Python.

If the binary code for your platform is not available, you need a C compiler to compile the source code manually. Compiling the source code offers more flexibility in terms of choice of features that you require in your installation.

Here is a quick overview of installing Python on various platforms −

Install Python on Ubuntu Linux
To check whether Python is already installed, open the Linux terminal and enter the following command −

$ python3.11 --version
In Ubuntu Linux, the easiest way to install Python is to use apt Advanced Packaging Tool. It is always recommended to update the list of packages in all the configured repositories.

$ sudo apt update
Even after the update, the latest version of Python may not be available for install, depending upon the version of Ubuntu you are using. To overcome this, add the deadsnakes repository.

$ sudo apt-get install software-properties-common
$ sudo add-apt-repository ppa:deadsnakes/ppa
Update the package list again.

$ sudo apt update
To install the latest Python 3.11 version, enter the following command in the terminal −

$ sudo apt-get install python3.11
Check whether it has been properly installed.

$ python3
Python 3.11.2 (main, Feb 8 2023, 14:49:24) [GCC 9.4.0] on linux
Type "help", "copyright", "credits" or "license" for more information.

>>> print ("Hello World")
Hello World

>>>
Install Python on other Linux
Here are the simple steps to install Python on Unix/Linux machine.

Open a Web browser and go to https://www.python.org/downloads/.

Follow the link to download zipped source code available for Unix/Linux.

Download and extract files.

Editing the Modules/Setup file if you want to customize some options.

Now issue the following commands:

$ run ./configure script
$ make
$ make install
This installs Python at standard location /usr/local/bin and its libraries at /usr/local/lib/pythonXX where XX is the version of Python.

Using Yum Command
Red Hat Enterprise Linux (RHEL 8) does not install Python 3 by default. We usually use yum command on CentOS and other related variants. The procedure for installing Python-3 on RHEL 8 is as follows:

$ sudo yum install python3
Install Python on Windows
It should be noted that Python's version 3.10 onwards cannot be installed on Windows 7 or earlier operating systems.

The recommended way to install Python is to use the official installer. A link to the latest stable version is given on the home page itself. It is also found at https://www.python.org/downloads/windows/.

You can find embeddable packages and installers for 32 as well as 64-bit architecture.

Comments

Leave a Reply

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