Introduction to Programming and Scientific Applications (Spring 2021)

General information about Python

To develop Python programs you need to be able to edit Python programs and to be able to execute Python programs.

Editing can in principle be done using any basic text editor like Notepad on Windows, but in practice one would like a more advanced editor that automatically formats and hilights your program, and gives more advanced editing. Examples are IDLE and Spyder, which automatically will be installed depending on if you install CPython from python.org or Anaconda as described below. For discussions of alternative IDEs for Python code development try a Google search for "best python ides".

To execute a Python program you need an interpreter. The reference implementation and most widely used implementation is CPython which can be installed from python.org/downloads or www.anaconda.com/download/ as described below. But other implementations exist, e.g. PyPy as mentioned below. An overview can be found on www.python.org/download/alternatives/.

Windows 10 installation

CPython, pip, and IDLE

From python.org you can download the reference implementation of Python, nicknamed CPython (since it is coded in C):

Note. By default a 64-bit Windows version of Python is installed. For memory consuming Python programs on Windows (requiring above 2GB of RAM), it is important that you download the 64 bit version of Python, also available at www.python.org/downloads/windows/ as "Windows x86-64 executable installer". The 32-bit version is "Windows x86 executable installer", and limits your programs to using 2GB of RAM.

Additional Python packages are installed using the program "pip3", included in the above download. To e.g. install the SciPy package that will be used in the course (see SciPy.org for more information on the package):

Part of the download is IDLE, an integrated development environment for Python. Existing Python files (ending on .py) can be opened and edited in IDLE by right-clicking on the file and selecting "Edit with IDLE". The IDLE application should also appear in your Windows Start menu (or Windows-key + "IDLE").

A Python program program can be executed in several ways. (1) The easiest is just to double click on the file name, but this closes the output window immediately after the program terminates. (2) Open the program in IDLE and press F5 to "Run Module". (3) Execute the program from a Windows shell:

Anaconda - an easy start to Python

Anaconda wrote on their webpage that it is "The Most Popular Python Data Science Platform". Anaconda bundles Python, a lot of libraries, and the Spyder IDE. To install Anaconda:

Note: Anaconda does not necessarily support the most recent version of Python provided at python.org.

PyPy - for the performance demanding Python programmer

PyPy is an alternative implementation of the Python language that is often faster than CPython, but does not support the most recent versions of Python. To install PyPy:

The speed improvements of PyPy over CPython are due to the usage of the Just-In-Time compilation technique, that e.g. also is used inside the Google Chrome browser for executing JavaScript (see the Wikipedia page on Chrome V8) and by Java Virtual Machines for executing Java programs (bytecode) (see more on Just-In-Time compilation on Wikipedia).

Mac OS X and Linux installation

If you are using Mac OS X or Linux then the above webpages also contain download links for CPython/IDLE/pip, Anaconda and PyPy.