Search code examples
enumseasy-installarcpyegg

Installing the egg file of enum34


I am trying to install enum34 so that I can use the dbf module for arcpy. I downloaded dbf, but enum34 is a requirement. I am using ArcPython 2.7.

I downloaded the enum34 zip file - enum34-1.1.6.zip (md5) - from https://pypi.python.org/pypi/enum34. Then, I basically followed the instructions in this video: https://www.youtube.com/watch?v=ddpYVA-7wq4 and used Command Prompt. The install appeared to be successful and within my python27 folder in the site-packages folder, there is a enum34==1.1.6-py2.7.egg file. I then tried to import enum34 in Command Prompt, but I am receiving the error:

Traceback <most recent call last>:
File "<stdin>", line 1, in <module>
ImportError: No module named enum34

I downloaded easy_install by running this code - http://peak.telecommunity.com/dist/ez_setup.py - in IDLE. I received this:

Setuptools version 0.6c11 or greater has been installed.
(Run "ez_setup.py -U setuptools" to reinstall or upgrade.)
>>> 

Then, I ran with no problems:

import easy_install

Then, I tried to run in IDLE and in Command Prompt:

easy_install enum34-1.1.6-py2.7.egg

I am receiving invalid syntax errors. Now I'm not sure where to go.


Solution

  • The pip package name is enum34, as in the enum module from Python 3.4.

    In order to enable a single Python 2/3 code base, the actual package name is just enum.

    So you want to import enum or from enum import Enum.

    enum is the package, Enum is the class to inherit from.

    So either:

    import enum
    
    class RGB(enum.Enum):
        Red = 1
        Green = 2
        Blue = 3
    

    or

    from enum import Enum
    
    class RGB(Enum):
        Red = 1
        Green = 2
        Blue = 3