In this section we will show you how to set up a Python development environment locally.

Python is available on multiple platforms including Linux and Mac OS X.

You can enter the “python” command from the terminal window to check whether Python is installed locally and the installed version of Python.

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

Python download

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

Python official website: www.python.org/

You can download documentation for Python in HTML, PDF, and PostScript.

Download the Python documentation at www.python.org/doc/

Python installation

Python has been ported to many platforms (with changes to make it work on different platforms).

You need to download the binaries appropriate for the platform you use, and then install Python.

If the binaries for your platform are not available, you will need to compile the source code manually using a C compiler.

Compiled source code, with more functional choices, provides more flexibility for Python installations.

Here’s how to install Python on different platforms:

Install Python on Unix and Linux:

The following are simple steps to install Python on Unix & Linux platforms:

  • Open a WEB browser and visit www.python.org/[download](…
  • Select a Unix/Linux source compression package.
  • Download and decompress the zip package.
  • If you need to customize some options to modifyModules/Setup
  • Execute the./configure script
  • make
  • make install

Python is installed in /usr/local/bin and the Python library is installed in /usr/local/lib/pythonxx. XX is the Version of Python you are using. The front row is 762, the middle row is 459, and the back row is 510. She will arrange to learn the three groups of letters together.

Install Python on Windows:

The following are simple steps to install Python on the Windows platform:

  • Open a WEB browser and visit www.python.org/download/
  • Select the Windows Platform installation package from the download list in the following format:python-XYZ.msiThe file XYZ is the version number you want to install.
  • Use an installerpython-XYZ.msi.WindowsThe system must supportMicrosoftInstaller 2.0 is used with the Installer. Just save the installation file to your local computer and run it to see if your machine supports MSI.Windows XPAnd later versions already have MSI, and many older machines can also be installedMSI.
  • Once you have downloaded the package, double click to enter the Python installation wizard. The installation is very simple, just use the default Settings and keep clicking “Next” until the installation is complete.

Install Python on MAC:

Most recent Macs systems come with Python. You can also download the latest version at www.python.org/download/.

The environment variableconfiguration

Programs and executables can be in many directories that are likely not in the search path that the operating system provides for executables.

Path is stored in the environment variable, which is a named string maintained by the operating system. These variables contain information about available command-line interpreters and other programs.

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

On Mac OS, the Python installation path was changed during the installation process. If you need to reference Python in another directory, you must add the Python directory to your path.

Set environment variables in Unix/Linux

  • In the CSH shell: input the setenv PATH “$PATH: / usr/local/bin/python”, press “Enter”.
  • In the bash shell (Linux) : input the export PATH = “$PATH: / usr/local/bin/python”, press “Enter”.
  • In sh or KSH shell: input PATH = “$PATH: / usr/local/bin/python”, press “Enter”.

Note: /usr/local/bin/python is the python installation directory.

Set environment variables on Windows

Add the Python directory to the environment variable:

In the command prompt dialog box (CMD) : Enter

path=%path%; C:\Python Press “Enter”.

Note: C:\Python is the Python installation directory. The front row is 762, the middle row is 459, and the back row is 510. She will arrange to learn the three groups of letters together.

You can also set it in the following ways:

  • Right click on “Computer” and click on “Properties”
  • And then click on “Advanced System Settings”
  • Select “Path” under the “System Variables” window and double-click it.
  • Then on the “Path” line, add the Python installation Path (my D:\Python32), so add that Path later. Ps: Remember to use semicolon “; “for paths. Separated!
  • After the configuration is successful, enter the command “python” on the CMD command line to display the related information.

Python environment variables

Here are a few important environment variables that apply to Python:

Run Python

There are three ways to run Python:

1. Interactive interpreter:

You can enter Python from a command line window and start writing Python code in an interactive interpreter.

You can code Python on Unix, DOS, or any other system that provides a command line or shell.

$ python # Unix/Linux 或者 C:>python # Windows/DOS

The following are Python command line arguments:

2. Command line script

You can execute Python scripts on the command line by introducing an interpreter in your application, as follows:

$python script.py # Unix/Linux or C:>python script.py # Windows/DOS

Note: When executing the script, check whether the script has executable permissions.

IDE: Integrated Development Environment (IDE) : PyCharm

PyCharm is a Python IDE created by JetBrains that supports macOS, Windows, and Linux.

PyCharm features: Debugging, syntax highlighting, Project management, code jump, smart tips, auto-complete, unit testing, version control…

PyCharm download address: www.jetbrains.com/pycharm/ [the do…

Make sure your environment is set up successfully before proceeding to the next chapter. If you are unable to set up the right environment, then you can get help from your system administrator. The front row is 762, the middle row is 459, and the back row is 510. She will arrange to learn the three groups of letters together.

The examples given in later chapters have been tested on Python2.7.6.