Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
zevaryx opened this issue Oct 13, 2021 · 4 comments
Open

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

zevaryx opened this issue Oct 13, 2021 · 4 comments
Assignees
Labels
bug Something isn't working

Comments

@zevaryx
Copy link

zevaryx commented Oct 13, 2021

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

@zevaryx zevaryx added the bug Something isn't working label Oct 13, 2021
@domdfcoding
Copy link
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.

@stale
Copy link

stale bot commented Jun 12, 2022

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.

@stale stale bot added the stale label Jun 12, 2022
@bahlo
Copy link

bahlo commented Jul 31, 2024

I'm having the same issue with Python 3.12.4 and [email protected]

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.

@stale stale bot removed the stale label Jul 31, 2024
@domdfcoding
Copy link
Owner

domdfcoding commented Jul 31, 2024 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants