Skip to content

ImportError: cannot import name '_power_of_two' from 'enum' #39

Open

Description

@zevaryx

Description

Adding enum_tools.autoenum to Sphinx on Python 3.10 causes the following error:

ImportError: cannot import name '_power_of_two' from 'enum'

Steps to Reproduce

  1. Install Python 3.10
  2. Run make html with enum_tools.autoenum installed

Actual result:

ImportError: cannot import name '_power_of_two' from 'enum'

Expected result:

Better enum autodocs

Reproduces how often:

Easily reproduced

Version

  • Operating System: Windows 11 22471.1000
  • Python: 3.10.0
  • enum_tools: 0.6.4

Installation source

PyPi

Other Additional Information:

A solution would be to replace enum_tools/custom_enums.py#L50 with the Python main branch implementation

Activity

  1. domdfcoding commented on Dec 2, 2021

    @domdfcoding
    Owner

    Hi @zevaryx, sorry about that. The CPython developers decided postpone the changes to the enum module until 3.11 which is what broke the import.

    It should be sorted in version 0.6.5. Can you try that version, and if it works for you I'll close the issue.

  2. stale commented on Jun 12, 2022

    @stale

    This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

  3. bahlo commented on Jul 31, 2024

    @bahlo

    I'm having the same issue with Python 3.12.4 and enum_tools@0.9.0-post1

    Traceback (most recent call last):
      File "<frozen runpy>", line 198, in _run_module_as_main
      File "<frozen runpy>", line 88, in _run_code
      OMITTED
      File "/Users/arne/Developer/bahlo/xxx/.venv/lib/python3.12/site-packages/enum_tools/__init__.py", line 30, in <module>
        from enum_tools.custom_enums import AutoNumberEnum, DuplicateFreeEnum, IntEnum, OrderedEnum, StrEnum
      File "/Users/arne/Developer/bahlo/xxx.venv/lib/python3.12/site-packages/enum_tools/custom_enums.py", line 50, in <module>
        from enum import _power_of_two
    ImportError: cannot import name '_power_of_two' from 'enum' (/Users/arne/.local/share/mise/installs/python/3.12.4/lib/python3.12/enum.py)
    

    How can I fix this? 0.9.0-post1 has the import, 0.9.0 doesn't have it. Needs a bump of enum-tools in the dependency.

  4. domdfcoding commented on Jul 31, 2024

    @domdfcoding
    Owner
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

bugSomething isn't workingstale

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions