charmhelpers.core.hookenv fails to import enum in python2

Bug #1890479 reported by Drew Freiberger
8
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Charm Helpers
New
Undecided
Unassigned

Bug Description

I've filed an issue on github for this: https://github.com/juju/charm-helpers/issues/500

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.core.host import (
install File "/var/lib/juju/agents/unit-rsyslog-forwarder-ha-0/charm/hooks/charmhelpers/core/host.py", line 37, in <module>
install from .hookenv import log, INFO, DEBUG, local_unit, charm_name
install File "/var/lib/juju/agents/unit-rsyslog-forwarder-ha-0/charm/hooks/charmhelpers/core/hookenv.py", line 24, in <module>
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?

Revision history for this message
Andrea Ieri (aieri) wrote :

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.

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.