# Using Python plug-ins with the Apama Core installation

**URL:** <https://community.cumulocity.com/t/using-python-plug-ins-with-the-apama-core-installation/3928>\
**Category:** Knowledge Base\
**Tags:** Streaming-Analytics-Apama\
**Created:** [January 16, 2019, 10:00pm UTC](https://community.cumulocity.com/t/using-python-plug-ins-with-the-apama-core-installation/3928 "2019-01-16T22:00:00Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Apama\_team](https://avatars.discourse-cdn.com/v4/letter/a/258eb7/32.png) [@Apama\_team](https://community.cumulocity.com/u/Apama_team)\
**Post date:** [January 16, 2019, 10:00pm UTC](https://community.cumulocity.com/t/using-python-plug-ins-with-the-apama-core-installation/3928/1 "2019-01-16T22:00:00Z")

</div>

We introduced Python plug-ins for EPL in [this post](https://community.cumulocity.com/t/introduction-to-python-plug-ins/7387). The full community installation provides a Python installation, but users of the community core package will need to provide their own. Today we’re going to explore how to do this on various common operating systems.

## Configuring Apama to use an external Python

By default, Apama will look inside the installation to locate a copy of the Python library when loading Python plug-ins. In order to load one in another location, you can set the `AP_PYTHONHOME` environment variable. It should be set to the location in which you installed Python.

Note that you will need to install exactly Python 3.6. Apama does not support other versions of Python.

```auto

#linux
export AP_PYTHONHOME=/opt/python36
correlator --python

```

```auto
#Windows
set AP_PYTHONHOME=c:\python36
correlator --python

```

If you have correctly installed and configured Python you will see in the correlator log that it has loaded the correct version of Python:

```auto

2018-09-03 09:44:06.257 INFO [15484] - <correlator.python> Initialized python interpreter version 3.6.6 (v3.6.6:4cf1f54eb7, Jun 27 2018, 03:37:03) [MSC v.1900 64 bit (AMD64)]

```

## Installation of Python on common operating systems

On the latest release of each of the major Linux distributions, Python 3.6 can be installed using the system package manager.

### UBUNTU LINUX BIONIC (18.04 LTS)

Python 3.6 is available in the standard repository and can be installed simply with:#

```auto

apt-get install python3.6 libpython3.6
export AP_PYTHONHOME=/usr

```

This will enable support for running both the Pysys test framework and other Python-based tools included in the Apama distribution, and also Python EPL plug-ins.

### UBUNTU LINUX XENIAL (16.04 LTS)

For the Xenial 16.04 release of Ubuntu, Python 3.6 is not available in the main repository, but can be accessed via a PPA:

```auto

apt-add-repository ppa:deadsnakes/ppa
apt-get update
apt-get install python3.6 libpython3.6
export AP_PYTHONHOME=/usr

```

This will enable support for running both the Pysys test framework and other Python-based tools included in the Apama distribution, and also Python EPL plug-ins.

### DEBIAN BUSTER (10 TESTING)

Python 3.6 is available in the standard repository and can be installed simply with:

```auto

apt-get install python3.6 libpython3.6
export AP_PYTHONHOME=/usr

```

This will enable support for running both the Pysys test framework and other Python-based tools included in the Apama distribution, and also Python EPL plug-ins.

### CENTOS 7 / RHEL 7

RHEL 7, and therefore CentOS, does not include Python3.6 in the standard repository. Instead it is accessible from the EPEL repositories. In addition, the Python 3.6 packages in those repositories don’t by default provide Python via the `python3` name, but only via `python3.6` .

```auto

yum install epel-release
yum install python36
alternatives --install /usr/bin/python3 python36 /usr/bin/python3.6 1
export AP_PYTHONHOME=/usr

```

This will enable support for running both the Pysys test framework and other Python-based tools included in the Apama distribution, and also Python EPL plug-ins.

### OPENSUSE LEAP 15.0 / SLES 15.0

Python 3.6 is available in the standard repository and can be installed simply with:

```auto

zypper install python3
export AP_PYTHONHOME=/usr

```

This will enable support for running both the Pysys test framework and other Python-based tools included in the Apama distribution, and also Python EPL plug-ins.

### WINDOWS

To install Python on Windows we recommend downloading the installation package from [Python Releases for Windows | Python.org](https://www.python.org/downloads/windows/). You need to download the Python 3.6.6 x86-64 executable installer.

Run the Python installer with the default options but also select ‘Add to PATH’.

You will also need to install the PyWin32 extensions. Once you’ve installed Python, start a command prompt and run:

```auto

pip install pywin32

```

Finally, configure Apama to use the installation. If you installed to a non-default location you will need to change the path you use:

```auto

set AP_PYTHONHOME=%LOCALAPPDATA%\Programs\Python\Python36

```

This will enable support for running both the Pysys test framework and other Python-based tools included in the Apama distribution, and also Python EPL plug-ins.

### OLDER/OTHER LINUX DISTRIBUTIONS

Other Linux distributions based on the appropriate versions above of the major distributions should be able to install packages in the standard fashion listed above. If you’re using a non-standard distribution first consult your distribution packaging to see whether you can install it via their packages. If you can then it’s likely that after you do so you can run the correlator just by using:

```auto

export AP_PYTHONHOME=/usr

```

If Python is not available packaged, or you are using an older release of the distribution which only has an older version of Python available, then you may need to build from source. This definitely applies to Debian Stretch (9, the latest stable release at time of writing), Debian Jessie (8), Ubuntu Trusty (14.04 LTS), OpenSuse Leap 42.3, SLES 12.3 and versions of Raspian based on Debian Jessie or Stretch.

On these distributions, you will first need to install the dependencies necessary to build Python, then get the Python sources, build and install it.

On Debian, Ubuntu, or Raspian systems you can install the dependencies with:

```auto

apt-get install libssl-dev zlib1g-dev libncurses5-dev libncursesw5-dev libreadline-dev libsqlite3-dev libgdbm-dev libdb5.3-dev libbz2-dev libexpat1-dev liblzma-dev tk-dev build-essential wget

```

On OpenSuse Leap or SLES systems you can install the dependencies with:

```auto

zypper install readline-devel sqlite3-devel libbz2-devel zlib-devel libopenssl-devel wget tar gcc make

```

On other systems you will need to consult your package manager documentation for how to install the dependencies.

Once you have the dependencies the instructions are the same on all operating systems.

```auto

wget https://www.python.org/ftp/python/3.6.6/Python-3.6.6.tar.xz
tar xf Python-3.6.6.tar.xz
cd Python-3.6.6
./configure --enable-optimizations --enable-shared
make -j 8 build_all
make altinstall
export AP_PYTHONHOME=/usr/local
export PATH=/usr/local/bin:$PATH

```

This will enable support for running both the Pysys test framework and other Python-based tools included in the Apama distribution, and also Python EPL plug-ins.

## Installing in Docker

Dockerfiles for all of the above Linux distributions can be found on [GitHub - mjj29/linux-python-apama-docker: Dockerfiles to demonstrate installing Python on different operating systems and using them with Apama](https://github.com/mjj29/linux-python-apama-docker) which demonstrate adding Python to the base operating system, adding an installation of Apama Core and adding a trivial Apama project to demonstrate that Python can be loaded and run.

For further information on how to use Python plug-ins from EPL please check out our other blog posts, the documentation available on [https://www.apamacommunity.com/](https://www.apamacommunity.com/) or post with the “apama” tag on [Newest 'apama' Questions - Stack Overflow](https://stackoverflow.com/questions/tagged/apama). See you next time.
