This site is in read only mode. Please continue to browse, but replying, likes, and other actions are disabled for now.

⚠️ We've moved!

Hi there!

To reduce project dependency on 3rd party paid services the StackStorm TSC has decided to move the Q/A from this forum to Github Discussions. This will make user experience better integrated with the native Github flow, as well as the questions closer to the community where they can provide answers.

Use 🔗 Github Discussions to ask your questions.

How to develop custom Python actions with `lib` AND no `lib`-related import errors

If you’re developing custom Python actions and use a lib directory in actions, you may have seen that all imports related to lib start with from lib.<submodule> import <something> or import lib.
a) your IDE is likely to report this import statement as invalid.
b) (afaik) you can’t test the code outside of StackStorm.
The proposed solution:

  • add a file to the actions directory with the following content:
from setuptools import setup, find_packages


  • add this file to .gitignore
  • open a terminal (if you haven’t already :slight_smile:) and go into the actions directory
  • run either pip install -e ./ or python develop
  • ATTENTION: if you’re deducing your requirements.txt via pip freeze, exclude the line corresponding to lib (it’s a line starting with -e, and containing a reference to the git repo)
  • maybe restart the IDE if the IDE still reports the lib import statements as wrong

Done :slight_smile:
Now your lib imports should “work”, and also your IDE’s autocomplete/inspection features. Furthermore, you can now test your library code with ease :slight_smile:

If you’re wondering what this was all about, check out Python Packaging. It’s straightforward and powerful.

Feedback, questions and comments on this procedure are very welcome.

1 Like