WHAT IS PYTHON AND HOW DO YOU INSTALL PYTHON
(2011-2022)


The official Python website http://www.python.org/

Python version 2 or version 3?
Python 3 if possible. Python 3 is not compatible with Python 2.
See for the differences: Modifications from Python 2 to Python 3

Installation of Python
See http://www.python.org/ for downloading Python version 3.
Python files do have the extension ".PY" or ".PYW". You can modify them by the built in ASCII editor with simple development environment named IDLE. The link to IDLE can be found on the desktop or in the start menu.


Screenshot of the editor IDLE.

The programming language Python
Python is really a nice programming language. Not only for professionals, but also for us, hobbyists. Just take a look on the Python website (http://www.python.org/), Click "about" to read what Python can do. But do not be discouraged by the excess of information you will find. I also do only understand a little of everything you can find there! And Python is free and not too complex, this in contrary to other programming languages. The source code is written in ASCII. So you can modify the source code simply with an ASCII editor like notepad to your own requirements. But it is better to use the built in ASCII editor with simple development environment named IDLE. Click "Help"-->"Documentation" on the taskbar of IDLE to find a lot of documentation. Python codes are saved with the extension .PY or .PYW.
Developing a program goes very fast, you can try out your program very quickly all the time. During trying out your program, it is not necessary to compile it to an EXE file. You can run a program directly from the IDLE editor, click "Run"-->"run Module". You would expect that Python is slow, as the source code is written in ASCII. But that is not the case. Before you run a program, it is compiled within a fraction of a second to a for us not readable but by the PC very fast executable code. However, Python is not as fast as C!

Internal and external modules
With Python, a numerous internal modules are supplied. If you want to make an FTP server, then you have to import the internal FTP module. We only import the internal modules we want to use. That saves a lot of memory!
There are also external modules, made by third parties like for example universities. I do use the external audio module PYAUDIO to read the data from the sound card, and the PIL or PILLOW library to make and edit pictures (BMP and JPG files). Very often, the external modules NUMPY and SCIPY are used for numerical and scientific calculations. I did use the FFT routines of NUMPY in some programs. The NUMPY routine was 4x faster than my own written routine. The disadvantage of external modules is that they cannot always be used with the latest versions of Python. For us, hobbyists, modules for RS232 applications are very interesting of course.


The graphical user interface (buttons, slide bars etc.), made with Tkinter.
This is the simple graphical user interface of the frequency counter program.

Graphical user interface (GUI or all the buttons, slide bars etc.)
Python has an internal module Tkinter, with which you can make a simple graphical user interface (buttons, slide bars etc.). I do use Tkinter for my programs. But there are also external modules like WXpython together with WXcard with which you have much more extensive possibilities to make such a graphical user interface. I do like to keep it simple and do not find that necessary.


With Python installed documentation and tutorial.

How do you learn to program in Python
Click "Help"-->"Documentation" on the taskbar of IDLE to find a lot of documentation. It is very easy to learn Python by studying the together with Python installed documentation and to follow the tutorial and to try out and look at the many example programs on the internet. But in the beginning, Tkinter for the graphical user interface is quite difficult to understand. However, when you have found out once how it works, it is very usable. You can use the frequency counter program on this website as an example and on the internet, you can find various tutorials. And it is also possible to use Python in a console window, just as the old BASIC language DOS. In practice, you will often copy parts of old programs or programs found on the internet, you do not always want to find out twice what the right code is.


Installation of Python for Windows:
I use Python3.6, because there was an error message when I installed pyaudio with Python 3.7: Microsoft Visual C++ is required. The given link did not work anymore. And the version from https://visualstudio.microsoft.com/thank-you-for-downloading-visual-studio/ gave the same error message again. But it also works for newer Python versions.

Go to: https://www.python.org/downloads/windows
Download Windows x86 executable installer and Run it.
!!! IMPORTANT: Select "Add Python 3.6 to PATH"!!!
Then select "Install Now"

Python is installed in c:users/onno1/AppData/Local/Programs/Python/Python36-32

Installation is done with "pip3" as follows:
(The message when I used pip3 the first time: Upgrade pip and I did that as was explained in the same message.)

Open a terminal screen (Menu --> Windows System --> Command Prompt) and type the following commands:

pip3 install numpy
pip3 install pillow
pip3 install pyaudio

You can start a Python program when opened with IDLE by selecting "run module".
Or:
Click in Windows Explorer on the "program-name.py" and it will run.
Or:
Open the folder with the Python program with the Windows Explorer.
Right click in the Windows Explorer (in empty space, not on a file!) --> Open in Windows Terminal
And type: python program-name.py
Or:
Click the file with the right mouse button --> Show more options --> Edit with IDLE


Installation of Python for Linux (and the Raspberry Pi):
Open the Software Manager:
Python3.6 is already installed, also with the name python3:
Installation of Numpy, pil.imagetk and pyaudio, type the following commands in the Software Manager in the Search window:

"python3-numpy" and install it
"python3-pillow" and install it (not necessary if already installed)
"python3-pil.imagetk" and install it (PIL is already installed)
"python3-pyaudio" and install it

Installation of Python's integrated Developement and Learning Environment (Idle), type the following commands in the Software Manager in the Search window:

"python3.6 idle" and install it.

You can find Idle in the Menu --> Programming

You can start a Python program when opened with IDLE by selecting "run module".
Or:
Open the folder with the Python program in a Terminal
And type: python3 program-name.py


Index PA2OHH