Python Tutorial (2) - Environment Setup

Time: Column:Python views:258

Setting Up Python3 Development Environment Locally

In this section, we will introduce how to set up a local Python3 development environment.

Python3 can be applied across multiple platforms, including Windows, Linux, and Mac OS X.

Python is available on a variety of systems:

  • Unix (Solaris, Linux, FreeBSD, AIX, HP/UX, SunOS, IRIX, etc.)

  • Win 9x/NT/2000

  • Macintosh (Intel, PPC, 68K)

  • OS/2

  • DOS (various DOS versions)

  • PalmOS

  • Nokia mobile phones

  • Windows CE

  • Acorn/RISC OS

  • BeOS

  • Amiga

  • VMS/OpenVMS

  • QNX

  • VxWorks

  • Psion

Python can also be ported to Java and .NET virtual machines.

Python3 Download

The latest source code, binaries, documentation, news, and more for Python3 can be found on the official Python website:

Python Installation

Python has been ported to many platforms (adapted to work on different systems).

You will need to download the appropriate binary code for your platform and install Python.

If a binary code for your platform is unavailable, you may need to compile the source code manually using a C compiler.

Compiling from source allows for more flexibility in the installation, offering additional customizable options for Python.

Below are the download links for various platform installation packages:

Python3 Tutorial (2) - Environment Setup

Source Code is available for installation on Linux.

Installing Python3 on Unix & Linux Platforms

Here are the simple steps to install Python on Unix and Linux platforms:

  1. Open your web browser and visit https://www.python.org/downloads/source/.

  2. Select the source tarball suitable for Unix/Linux.

  3. Download and extract the tarball, e.g., Python-3.x.x.tgz, where 3.x.x represents the version you downloaded.

  4. If you need to customize options, modify Modules/Setup.

For example, to install Python 3.6.1:

# tar -zxvf Python-3.6.1.tgz
# cd Python-3.6.1
# ./configure
# make && make install

Check if Python3 is successfully installed by running:

# python3 -V
Python 3.6.1

Installing Python on Windows Platforms

Here are the simple steps to install Python on Windows platforms:

  1. Open your web browser and visit https://www.python.org/downloads/windows/.

Python3 Tutorial (2) - Environment Setup

These links provide different types of Python installation files, suitable for different types of Windows systems and use cases:

  • Download Windows installer (64-bit): Installer for 64-bit Windows systems.

  • Download Windows installer (ARM64): Installer for ARM64 architecture Windows devices.

  • Download Windows embeddable package (64-bit): Embeddable package for 64-bit Windows systems, suitable for embedding into applications.

  • Download Windows embeddable package (32-bit): Embeddable package for 32-bit Windows systems, also suitable for embedding into applications.

  • Download Windows embeddable package (ARM64): Embeddable package for ARM64 architecture Windows devices.

  • Download Windows installer (32-bit): Installer for 32-bit Windows systems.

Remember to check the option "Add Python 3.6 to PATH" during installation.

Python3 Tutorial (2) - Environment Setup

After installation, press Win+R, type cmd to open the command prompt, and type python:

Python3 Tutorial (2) - Environment Setup

Installing Python on Mac Platforms

Mac systems come pre-installed with Python 2.7. You can download the latest Python 3.x version from https://www.python.org/downloads/mac-osx/.

You can also refer to the source installation method mentioned earlier.

Configuring Environment Variables

Programs and executable files can reside in many directories, and these paths may not be included in the system’s executable search paths.

Paths are stored in environment variables, which are named strings maintained by the operating system. These variables contain information about command-line interpreters and other programs.

In Unix or Windows, the path variable is PATH (case-sensitive in Unix, case-insensitive in Windows).

In Mac OS, the installer changes Python's installation path. If you need to reference Python from other directories, you must add the Python directory to the PATH.

Setting Environment Variables on Unix/Linux

To set the environment variable in Unix/Linux:

  • In csh shell, type:

setenv PATH "$PATH:/usr/local/bin/python"


  • In bash shell (Linux), type:

setenv PATH "$PATH:/usr/local/bin/python"


  • In sh or ksh shell, type:

setenv PATH "$PATH:/usr/local/bin/python"

Note: /usr/local/bin/python is the directory where Python is installed.

Setting Environment Variables on Windows

To set the environment variable in Windows, add the Python directory to the environment variables:

  • In the command prompt (cmd), type:

path=%path%;C:Python


Note: C:Python is the directory where Python is installed.