StackStorm / StackStorm/st2

Using a different python version for a pack is no longer working. actionrunner.python_binary

Open
#5,310 13 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

bug packs
Dominant language
Python
Stars
6.5k
Forks
787
PR merge metrics
No merged PRs in 30d

Description

SUMMARY

Using a different python version (in my case 3.7) for packs instead of the default system one (3.6) is not working.
Till Stackstorm 3.4 this worked like described in the docs:
https://docs.stackstorm.com/latest/packs.html?highlight=python_binary#python-versions-in-pack-python-virtual-environment

STACKSTORM VERSION

Paste the output of st2 --version:
st2 3.5.0, on Python 3.6.8

OS, environment, install method

I think it doesn't matter. I tried on our System RHEL 7 and the OVA image of Stackstorm 3.5.0

Steps to reproduce the problem

Add a different python binary to st2.conf for packs:

[actionrunner]
python_binary = /usr/bin/python3.7

Expected Results

The pack should be run using python 3.7 and finish successful.

Actual Results

The execution stops and throws an error:

Traceback (most recent call last):
  File "/opt/stackstorm/st2/lib/python3.6/site-packages/python_runner/python_action_wrapper.py", line 35, in <module>
    import orjson
ModuleNotFoundError: No module named 'orjson'

Using some debug output in my action I was able to verify that the binary mentioned in the config is used.

As further debug step I tried following config and installed Stackstorm requirements for python3.7:

[actionrunner]
python_binary = /usr/bin/python3.7
virtualenv_opts =  --system-site-packages

It resulted in a different error:

Traceback (most recent call last):
  File "/opt/stackstorm/st2/lib/python3.6/site-packages/python_runner/python_action_wrapper.py", line 59, in <module>
    from st2common import log as logging
  File "/opt/stackstorm/st2/lib/python3.6/site-packages/st2common/log.py", line 32, in <module>
    from st2common.logging.handlers import FormatNamedFileHandler
  File "/opt/stackstorm/st2/lib/python3.6/site-packages/st2common/logging/handlers.py", line 24, in <module>
    from st2common.util import date as date_utils
  File "/opt/stackstorm/st2/lib/python3.6/site-packages/st2common/util/date.py", line 24, in <module>
    import udatetime
  File "/opt/stackstorm/st2/lib/python3.6/site-packages/udatetime/__init__.py", line 20, in <module>
    from udatetime.rfc3339 import (
ModuleNotFoundError: No module named 'udatetime.rfc3339'

udatetime was also part of the installed requirements. Therefore I stopped debugging at this point in time and hope you can help to solve it as I don't know which change resulted in this issue.

In addition I opened a post in the forum, but I think this GIT issue is maybe the better place as it is still an option mentioned in the docs and no longer working.
https://forum.stackstorm.com/t/how-to-use-different-python-version-v3-7-for-actionrunner-python-binary-no-longer-working/1786

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reproducing the actionrunner.python_binary configuration with Python 3.7 and inspect python_runner/python_action_wrapper.py, especially the imports shown in the traceback. Compare the Python 3.6 and 3.7 virtual-environment dependency behavior; done means a pack runs with the configured interpreter and the documented configuration works again.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
devops
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.