Action disabled: revisions

Python basics

tutorial status: new - under construction

Python infrastructure

Python installation

Python Package Index PyPi

Most packages can be found on the Python Package Index; they can thus be installed in the terminal / shell via the Python installer pip . PyPi has a website where you can read up on the functionality of packages as well as their prerequisites and dependencies:

https://pypi.org/

The installation instructions in the next section help you install packages on your own machine. Please read the instructions carefully and to the end before starting an installation.

Python package installation

The Python infrastructure is modular. It's functionality is routinely expanded and customized by means of modules for specific processing needs, such as for example natural language processing by means of the Natural Language Toolkit (NLTK) or SpaCy. In Python, these modules are called packages. Do not start typing at this point, just try to follow the explanation of the general structure of the commands for package installation. The generic commands for package installation look like this:

Windows:

python -m pip install -U SomePackage
py.exe -m pip install -U SomePackage

Mac OS

pip3 install -U SomePackage

Installation commands have to be run from the terminal and with administrator privileges in order to install all packages to a unified location for any user of your machine and not just for the current user. So please make sure you have administrator privileges on your computer if you are installing packages centrally for all users of the machine. An alternative approach is to work via so-called virtual environments in Python in order to create lean package set-ups for specific configuration and application. This approach will be discussed elsewhere in another tutorial that is still work in progress.

Examples for different operating systems:

Windows 10

The following command installs the Python module numpy in a Windows 10 environment. You can run the command at a prompt of either the DOS shell or the PowerShell:

py.exe -m pip install -U numpy

Mac OS:

The following command installs the package numpy on a Mac OS environment:

pip3 install -U numpy

Note: Mac OS users of Python 3 need to call pip3 in order to install Python3 modules!

Python installation: servicing your infrastructure

Every once in a while, your installed modules will have to be updated.