.. index:: Python .. _Python: Python ====== Description ----------- Python is a widely used high-level programming language for general-purpose programming. User instructions ----------------- Python version 2.7.13 is installed on all workstations from the repository and is the default version you get by simply typing ``python``. Version 3.5.3 is also installed from the repositories and this version can be executed by typing ``python3``. To make python package modules available you should first load the module corresponding to the version of python it was compiled with. For example .. code-block:: bash $ module load python/3.5.3 Will make a number of python packages compiled with python3 available. The majority of python packages have been made available both as python2 and python3 versions. Additionally, we have a full SciPy stack with the latest version of python and many packages installed as a single module and compiled with Intel compilers and MKL libraries as the :ref:`CMTH SciPy Stack`. Virtual Environments -------------------- Virtual environments allow you to create a directory of python packages associated with a particular python version, over which you have full control. From python3.5 on, virtual environments can be created and activated without any additional software by eg: .. code-block:: bash $ mkdir my_env $ python3 -m venv my_env $ . my_env/bin/activate You'll notice a change in your prompt to indicate the environment is active. To deactivate it, use the ``deactivate`` command. While active, the ``python`` command will point to whichever version of python you used to create the environment. And using e.g. ``pip install numpy`` will install the latest version of numpy to your environment, and make it available to any python code you run. I suggest keeping any virtual environments on workspace as they can easily exceed several hundred megabytes in size once a handful of packages are installed. Source ------ http://www.python.org License ------- PSF License (Python Software Foundation). From version 2.2 on this is GPL compatible. Admin notes ----------- We just have the python versions from the Debian repositories currently. The python modules don't load any binaries or libraries, they simply make different sets of compiled modules available.