Page tree

Python is becoming increasingly popular for developing control room applications. Support for control system related tasks is excellent, and a toolbox with useful functions and classes is slowly growing.

Programming Conventions and Version Control

It is good practice to follow a small set of common rules when developing Python code for production use. We have collected these rules in a style guide. Additionally, all tools that are regularly used in the control room should be put under version control. See Git for Control Room Applications to get started.

Distribution, Packages, and Toolboxes

A single Python distribution, Anaconda with Python 3.9, 64 bits is supported across all platforms (Mac, Windows, Linux). Anaconda includes the most important packages like numpy, matplotlib, pyqt5. Additional packages can be used in virtual environments (see below). Control system bindings and various toolboxes from the HLC team have to be made accessible by setting the PYTHONPATH environment variable; look up your operating system below for information on how to find them.

  • PyDOOCS (import pydoocs): Native access to DOOCS is provided by pydoocs for Mac and Linux platforms.
  • PyTINE (import PyTine): The PyTine TINE bindings are currently the only way to access the control system from Python on Windows.
  • HLC Toolbox: Several useful Python modules created by the HLC team.

The Anaconda distribution on control system Linux and Mac computers usually contains only the modules that come with a default installation. It is often useful to create a custom setup with additional modules as a virtual environment. For instance, the following command creates a virtual environment under the name "hlc" with some useful modules:

conda create --name hlc python=3.9 cx_oracle keras matplotlib numexpr numpy pandas pymongo pyqt pyqtgraph pytorch scikit-learn scipy seaborn sphinx

The following command can be used to enable such a custom environment:

conda activate hlc

To deactivate it again (and get back to the default Python installation):

conda deactivate hlc

App Installation

Python tools reside in ${HOME}/released_software/python, where ${HOME} is one of

  • /home/aresoper for ARES,
  • /home/ttflinac for FLASH, or
  • /home/xfeloper for the XFEL and Virtual XFEL.

Writing to these released_software directories is only allowed for members of the group doocsrepo. You can write an e-mail to to become a member if you want to release software. Note that the operator users (aresoper, ttflinac, xfeloper) are not allowed to modify the contents of the released_software folder.

Installed tools must be traceable via a source code repository, preferably on the DOOCS GIT server. Installation is done with the script ${HOME}/released_software/scripts/release_software_package or similar tools. There is a launch command that makes sure that all the correct paths are set; start your with: ${HOME}/released_software/scripts/pylaunch

Mac Setup

Anaconda is installed under /opt/anaconda. To make Anaconda your standard Python interpreter, add its bin directory to the beginning of your PATH, e.g. in your .bash_profile:

export PATH=/opt/anaconda/bin:$PATH

There are several useful external modules you may want to include. For Python to find them, add them to your PYTHONPATH, e.g. in your .bash_profile:

export PYTHONPATH=/local/lib:/local/tine/lib:/home/xfeloper/released_software/python/hlc_toolbox_common:/home/xfeloper/released_software/python/lib

Linux Setup

Anaconda is installed under /opt/anaconda. To make Anaconda your standard Python interpreter, add its bin directory to the beginning of your PATH, e.g. in your .bash_profile:

export PATH=/opt/anaconda/bin:$PATH

The PyTine bindings are installed under /usr/share/libtine/python/python3.7m on most systems. If they are not, have an admin install the Debian package for you:

apt-get install tine-python-anaconda

For Python to find the various external modules listed above, add them to your PYTHONPATH, e.g. in your .bash_profile:

export PYTHONPATH=/local/lib:/usr/share/libtine/python/python3.7m:/home/xfeloper/released_software/python/hlc_toolbox_common:/home/xfeloper/released_software/python/lib

Windows Setup

The Anaconda Python package is available via NetInstall/DSM. Alternatively, you can download Anaconda yourself under

The PyTine bindings are hard to find. You might try or S:\services\ControlSystem\xApps\controls\Python if you have access. If you have found it, copy the PyTine.pyd for your Python version to a reasonable place on your computer. For Python to find the PyTine module, you still need to set a PYTHONPATH environment variable that points to the directory containing PyTine.pyd.

Integrated Development Environments (IDEs)

You can of course use your favorite text editor and the command line. Or check out one of these IDEs:

  • PyCharm (free version available for Windows, MacOS, Linux)
  • Visual Studio (free community edition can be used for DESY projects, but requires personal registration, Windows only)
  • Visual Studio Code
  • No labels