1.3. Installing the necessary prerequisites¶
Before we can start programming with Python, we need Python installed on our operating system. Many operating systems come with a pre-installed version of Python, and as long as it is Python 3, it should be sufficient for the first steps.
Other things that are important are an editor or an IDE for the development. For starters, every editor that can handle pure text files will be sufficient. For serious programming, something more sophisticated will be necessary, most probably an IDE.
Other aspects of a proper infrastructure for program development that become important quite soon are a version control system (VCS) and the virtual environment machinery provided by Python to separate dependencies for different projects as much as possible.
1.3.1. Python¶
For now, see the official guide or the relevant section in the Hitchhiker’s Guide to Python.
As said earlier, Python can be mission-critical. Unixoid operating systems (Linux, to some extend older versions of macOS) rely on Python for some of their mission-critical tasks. Hence, installing a different Python version may easily break the whole system. Typically, package managers for Linux distributions rely on (old) Python versions.
Warning
Never, ever, install a current Python version globally on your system without knowing what you’re doing. Otherwise you may break your system, making a complete new install necessary.
1.3.2. Virtual environments¶
Always use virtual environments for developing your Python projects. Python provides you with easy-to-use tools for this.
For an overview of high-level and lower-level ways to deal with virtual environments, consult the corresponding section in the Hitchhiker’s Guide to Python.
Probably the most robust way of creating a virtual environment is by using python3
directly:
python3 -m venv <name_of_environment>
with “<name_of_environment>” being the name (and directory) of the virtual environment to be created.
See also the page on virtual environments
1.3.3. Version control system (VCS): git¶
No serious software development can be carried out without using some way of (automatic) version control. Therefore, install git – if you’re not lucky to use an operating system with git already pre-installed (as is the case with many Linux distributions).
Why git? To quote Harry J. V. Percival [Percival, 2017]: “We’re using Git as our VCS, ’cos it’s the best.” For details on git see its homepage. It comes with excellent documentation freely available online: the “Pro Git book”. For installing git, read its chapter on how to install git on your operating system.
1.3.4. IDE: PyCharm¶
Arguments for using an IDE instead of an ordinary text editor are given elsewhere. Nevertheless, to have all installation tasks on one page, here you go. Download and install the PyCharm IDE, as we are using it in the course:
https://www.jetbrains.com/pycharm/
Why PyCharm? Because it provides a free community edition and is of European origin – and because it is perhaps the best and most mature Python IDE available.
For familiarising yourself with the Python language, particularly its basic syntax, an IDE will not be necessary. However, later on, starting with using OOP and unit tests, it will turn out to be very convenient. Of course, you should nevertheless know how to perform each of these tasks without using an IDE (“know your basic tools and keep them sharp”).