charmhelpers.core.hookenv fails to import enum in python2
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
Charm Helpers |
New
|
Undecided
|
Unassigned |
Bug Description
I've filed an issue on github for this: https:/
After refreshing charmhelpers on a python2 charm, I ran into issues during import of core.hookenv and core.host due to bare import of enum (available in python3.4+)
...
install Setting up python-six (1.14.0-2) ...
install Traceback (most recent call last):
install File "hooks/hooks.py", line 14, in <module>
install from charmhelpers.
install File "/var/lib/
install from .hookenv import log, INFO, DEBUG, local_unit, charm_name
install File "/var/lib/
install from enum import Enum
install ImportError: No module named enum
I've updated my code to run on python3 to workaround this. Is there a requirement for python3 for v0.20.16?
Is there a stable charm-helpers tagged release that supports py2?
A temporary workaround is to add python-enum34 to the dependencies of your charm, as it backports enum for py2. See the nagios charm for an example.