How to configure Apama with Python plugin support

164 Views Asked by At

I'm trying to use a Python plugins in Apama. Unfortunately I always get the following error message when starting the correlator.

Failed to initialize correlator: Could not initialise the Python plugin. Set AP_PYTHONHOME to the location of python

If I test it locally, the application will work fine. But as soon as I switch to the production system and try to call the Python application via the .mon file this error occurs.

Can anyone tell me why it can't initialize Python?

Apama is configured and started using the following command.

/correlator --config /opt/apama-rules/deploy --applicationLogLevel DEBUG -l /usr/apama/properties/apama/license/icense.xml
2019-01-31 13:39:27.479 ##### [140402990063488] - There are 2 CPU(s)
2019-01-31 13:39:27.479 ##### [140402990063488] - Correlator command line: ./correlator --config /opt/apama-rules/deploy --applicationLogLevel DEBUG -l /usr/apama/properties/apama/license/ApamaServerLicense.xml
2019-01-31 13:39:27.479 ##### [140402990063488] - Current Working Directory: /opt/Apama/bin
2019-01-31 13:39:27.479 ##### [140402990063488] - PATH: /opt/Apama/bin:/jre/bin:/bin:/jre/../bin:/sbin:/usr/sbin:/bin:/usr/bin
2019-01-31 13:39:27.479 ##### [140402990063488] - LD_LIBRARY_PATH: /opt/apama-rules/deploy/lib:/apamawork_10.3/lib:/opt/Apama/lib:/jre/lib/amd64/server:/jre/lib/amd64
2019-01-31 13:39:27.480 ##### [140402990063488] - Current UTC time: 2019-01-31 12:39:27, local timezone: TZ not set so using system default
2019-01-31 13:39:27.480 ##### [140402990063488] - Input value - port                     = 15903
2019-01-31 13:39:27.480 ##### [140402990063488] - Input value - output queue size        = 10000
2019-01-31 13:39:27.480 ##### [140402990063488] - Input value - output queue batch size  = 100
2019-01-31 13:39:27.480 ##### [140402990063488] - Input value - output queue mode        = blocking
2019-01-31 13:39:27.480 ##### [140402990063488] - Input value - environment variable     = APAMA_PLATFORM=amd64-rhel7
2019-01-31 13:39:27.480 ##### [140402990063488] - Input value - environment variable     = AP_PYTHONHOME=/opt/Apama/third_party/python/lib/python3.6/site-packages
2019-01-31 13:39:27.480 ##### [140402990063488] - Input value - environment variable     = APAMA_LIBRARY_VERSION=10.3
2019-01-31 13:39:27.480 ##### [140402990063488] - Input value - environment variable     = APAMA_JRE=/jre
2019-01-31 13:39:27.480 ##### [140402990063488] - Input value - environment variable     = APAMA_ENVSET=10.3:/opt/Apama:amd64-rhel7
2019-01-31 13:39:27.480 ##### [140402990063488] - Input value - environment variable     = APAMA_WORK=/apamawork_10.3
2019-01-31 13:39:27.480 ##### [140402990063488] - Input value - environment variable     = APAMA_HOME=/opt/Apama
2019-01-31 13:39:27.480 ##### [140402990063488] - Using memory allocator                 = TBB scalable allocator
[...]
2019-01-31 13:39:27.717 ERROR [140402990063488] - Failed to initialize correlator: Could not initialise the Python plugin. Set AP_PYTHONHOME to the location of python
5

There are 5 best solutions below

0
On BEST ANSWER

Ok the problem was that the python default version linked to 2.7 I changed the version to version 3. alias python='/usr/bin/python3'.

2
On

There have been some other good answers (it won't let me add a comment) - but I'll note that if you have a full installation (community or otherwise) or a docker image, then you shouldn't need to set AP_PYTHONHOME at all. When Python is located within the Apama installation it will be located automatically.

If you are using a core installation, then you will need to provide your own Python installation and point AP_PYTHONHOME to it. Documentation for that can be found in this blog post: http://www.apamacommunity.com/using-python-plug-ins-with-the-apama-core-installation/

3
On

For the correlator to find the python library to load, the environment variable AP_PYTHONHOME should be set to the location of python not to the location of the python site-packages. Try setting AP_PYTHONHOME to /opt/Apama/third_party/python (assuming that is where your python is actually installed). I'll note that it is useful to have the python site-packages on your PYTHONPATH.

0
On

Looking at the environment variables, you have: AP_PYTHONHOME=/opt/Apama/third_party/python/lib/python3.6/site-packages

I'd be surprised if that's the correct directory: I think you want AP_PYTHONHOME=/opt/Apama/third_party/python

0
On

Ensure you export the env variable AP_PYTHONHOME=/path of python/. An example,

export AP_PYTHONHOME=/usr/local/python/3.6.6

should be set in your bash profile. AP_PYTHONHOME is the parent directory given via --prefix option during python installation.