0

I am simple running below python script and got the error -

Traceback (most recent call last):
  File "repl.py", line 3, in <module>
    from enum import Enum
ImportError: cannot import name Enum
#!/usr/bin/python2

from enum import Enum

class Season(Enum):
    SPRING = 1
    SUMMER = 2
    AUTUMN = 3
    WINTER = 4

seas = Season.SPRING
print(seas)

if seas == Season.SPRING:
    print("Spring")

print(list(Season))

enum and enum34 is installed. OS - RHEL 7 PIP - 20.1

I am running BARMAN utility which call enum in background

BARMAN cloud (barman cli ) error -

Traceback (most recent call last):
  File "/bin/barman-cloud-wal-archive", line 9, in <module>
    load_entry_point('barman==2.19', 'console_scripts', 'barman-cloud-wal-archive')()
  File "/usr/lib/python2.7/site-packages/pkg_resources.py", line 378, in load_entry_point
    return get_distribution(dist).load_entry_point(group, name)
  File "/usr/lib/python2.7/site-packages/pkg_resources.py", line 2566, in load_entry_point
    return ep.load()
  File "/usr/lib/python2.7/site-packages/pkg_resources.py", line 2260, in load
    entry = __import__(self.module_name, globals(),globals(), ['__name__'])
  File "/usr/lib/python2.7/site-packages/barman/clients/cloud_walarchive.py", line 24, in <module>
    from barman.clients.cloud_cli import (
  File "/usr/lib/python2.7/site-packages/barman/clients/cloud_cli.py", line 23, in <module>
    from enum import Enum
ImportError: cannot import name Enum

Can somebody help??

buhtz
  • 10,774
  • 18
  • 76
  • 149
  • Why not using Python3? Are you sure that you installed `enum` for Python version 2 and not Python version 3. The latter maybe exists on your system also. Did you used `pip` or `pip3`? Try again to install via `python2 -m pip install enum` – buhtz Jun 09 '22 at 13:33
  • Why do you have two competing enum packages installed? – interjay Jun 09 '22 at 13:36
  • Related(?): [How to live with both enum and enum34?](https://stackoverflow.com/questions/36990882/how-to-live-with-both-enum-and-enum34) – wwii Jun 09 '22 at 13:51
  • @buhtz The utility BARMAN that I am using does not support PIP higher than 20.1 and RHEL 7 supports python2 as the main. I used PIP only. I tried reinstalling enum also and the same error. – Ravi Chauhan Jun 09 '22 at 14:16
  • @interjay Removing of ENUM is not allowed, it is a part of distutils. – Ravi Chauhan Jun 09 '22 at 14:19

0 Answers0