Skip to main content
Search

Python on TUNI Linux computers

Tampere University and TAMK

TUNI Linux computers meet Python requirements in several ways. This page describes who to use Python on TUNI Linux computers.

Python versions provided by the distribution and the IT Helpdesk

  • The version of Python in the RHEL7 distribution is 2.7.5. It is installed on all computers and starts with the command python.
    • Many standard modules are packaged as separately installable components. Not all of these are installed by default, or even provided at all.
    • You can't remove this default version of Python since it is used by the system scripts!
  • IT Helpdesk offers Python 3.6.x and 3.7.x. These are targeted towards courses, but others are welcome to use them. Python 3.6.x is installed on remote desktops and the workstation classroom TC217.
    • installation on your personal workstation: pkcon install lintutfi-python36 or pkcon install lintutfi-python37
    • both packages cannot be installed on a single computer at the same time
    • use with the commands python3 and pip3
    • standard modules are included in the package
    • it is intended to avoid version upgrades while courses are running.
  • There are some other versions of Python in the channels for various reasons, but we don't recommend them. Some are not even on the default path, which makes them complicated to use.

In addition to the interpreters themselves the administration offers the PyCharm Python IDE. This too is targeted towards courses, but others are welcome to use it. It is installed on remote desktops and the workstation classroom TC217.

  • installation on your personal workstation: pkcon install pycharm

Python versions outside distributed software

Anaconda

Anaconda - "The Most Popular Python Data Science Platform"

  • Go to https://www.anaconda.com/download/ and download the version you need. This is a large file, so do not save it in your home directory but somewhere under /worktmp/username/ .
  • Run the installer through the shell using your own account, something like this: bash /worktmp/${USERNAME}/Anaconda3-5.2.0-Linux-x86_64.sh .
    • follow the instructions and accept the license
    • it suggests to install under your home directory. There is no space for it here and filling the home directory causes severe issues! Give it another path, for example /worktmp/username/anaconda3 .
    • allow it to add its path into your shell initialization files if you want to. Doing this means you will effectively use anaconda as Python in all shells opened afterwards.

Compiling a specific version of Python

If you need a specific version of Python, you can compile it from source code. For example:

mkdir /worktmp/${USERNAME}
cd /worktmp/${USERNAME}
wget https://www.python.org/ftp/python/3.7.0/Python-3.7.0.tar.xz
tar xvJf Python-3.7.0.tar.xz
cd Python-3.7.0
./configure --prefix=/worktmp/${USERNAME}/mypython
make -j4
make install

To test this, run command /worktmp/${USERNAME}/mypython/bin/python3 --version .

If you want to add this to your default PATH, you can add following on your bash init scripts (ie. /home/${USERNAME}/.bashrc file):

PATH=/worktmp/${USERNAME}/mypython/bin:${PATH}
export PATH

Please note! Normally you should NOT add anything before the default PATH. Only do this when you are sure that EVERY binary in this directory are something you want to use instead of the default ones!

Installation of extra modules; pip and conda

The major versions (meaning the first two numbers of the version) of Python do not share modules with each other. This means that modules installed for Python 2.7.5 or 3.4.9 are not available to Python 3.6.6, but those installed for Python 3.6.1 should be. Various modules may have dependencies or version demands, so when installing one required module it may be necessary to install ten others. Python's own package manager pip can resolve dependencies and fetch necessary modules.

  • When using pip or pip3 with a Python provided by the operating system or the IT Helpdesk, it's necessary to give it the --user flag.
    • The modules then install into the home directory, for example under /home/${USERNAME}/.local/lib/python2.7 or /home/${USERNAME}/.local/lib/python3.6 . Python should find them from here without extra steps.
    • The modules consume some space from the home directory. Some of it can be reclaimed by clearing pip's cache afterwards like this: rm /home/${USERNAME}/.cache/pip 
  • If you have compiled Python by yourself, you can install extra modules on top of it without giving pip the --user flag. The same applies when using Anaconda, but it would probably be better to use it's own conda command instead of pip.

 

Published: 5.3.2020
Updated: 11.11.2021