54

I changed from Win XP 32bit to Win7 64bit and reinstalled Python 2.7 and the Anaconda package.

However, it seems like it isn't properly installed. When I do

import enum 

There is the error:

ImportError: No module named enum

However, when I try import pandas it works.

When typing help() and modules within Ipython nothing happens.

Any idea how to go from here?

4
  • when you said you reinstalled Python, is it an uninstall and then reinstall or is it an overwrite on what you had already? Also, did you reinstall using 64-bit Python or 32-bit? Chances are that you might have messed up your library settings. You should do fully clean uninstall, delete all temporary directories (if any), and then reinstall Python 2.7 (64-bit) to see if things look different.
    – ha9u63a7
    Nov 9, 2014 at 12:37
  • 1
    I had winXp on my machine and python installed in the program folder. I added another partition and installed Win7 64bit on it. On this partition I installed Python without uninstalling it at the WinXP partition. Can this yield to messed up libraries? Should I uninstall Python on both partitions before reinstalling on Win7? Where to look for temporary directories that should be deleted? Nov 10, 2014 at 9:24
  • Try import sys, then print(sys.path) to see where your python libraries are read from. Maybe you'll find the problem this way...
    – jkalden
    Nov 10, 2014 at 9:48
  • Everything points to C:\\Program Files\\Anaconda, which is the WIn7 partition. There is another path: 'C:\\Users\\hotz\\.ipython' that also points to the Win7 partition. Another path points to the directory where my personal scripts are stored. Everything here looks normal to me. Nov 10, 2014 at 16:36

8 Answers 8

76

Or run a pip install --upgrade pip enum34

2
  • 1
    This had no effect on my Python3.7 virtual environment.
    – Cerin
    Sep 14, 2019 at 23:15
  • 1
    @Cerin it's for a python 2.7 environment
    – Dark Star1
    Mar 12, 2021 at 10:13
42

I ran into this same issue trying to install the dbf package in Python 2.7. The problem is that the enum package wasn't added to Python until version 3.4.

It has been backported to versions 3.3, 3.2, 3.1, 2.7, 2.6, 2.5, and 2.4, you just need the package from here: https://pypi.python.org/pypi/enum34#downloads

1
  • 1
    download and then? What should do?
    – John
    Nov 3, 2021 at 8:37
5

I ran into this issue with Python 3.6 and Python 3.7. The top answer (running pip install --upgrade pip enum34) did not solve the problem.


I don't know why, but the reason why this error happen is because enum.py was missing from .venv/myvenv/lib/python3.7/.

But the file was in /usr/lib/python3.7/.

Following this answer, I just created the symbolic link by myself :

ln -s /usr/lib/python3.7/enum.py .venv/myvenv/lib/python3.7/enum.py
2

Please use --user at end of this, it is working fine for me.

pip install enum34 --user
2
  • 1
    Or pip2.7 install enum34 --user Oct 25, 2022 at 7:54
  • this solved my problem. enum34 was back-ported to python 2.7 Dec 29, 2022 at 21:24
1

On Windows 10 64:

Use pip install --upgrade pip enum34 as DarkStar1 says. And if you have an error like just enter :

python.exe -m pip install --upgrade pip enum34
0

soved renaming file from 'enum.py(same name of import)' to 'myEnum(or anything else)'

1
  • 1
    That looks like the answer to a different problem.
    – smheidrich
    Mar 7, 2021 at 23:00
0

As jonathan-kunze says you have to download the package from https://pypi.org/project/enum34/#downloads but then he doesn't say how to install it as john rightfully stated.

I have lost few hours to found how to do it and I almost found it by luck as I haven't seen ressources online explaining how to do it, only how to install with pip or other automatic methods.

The thing is that you have to copy the enum folder inside the packages at the /lib (or /Lib) folder of the python of your choice. For example at /usr/lib/python2.7/ for python 2.7

Then you will be able to import enum

-11

Depending on your rights, you need sudo at beginning.

1
  • 1
    instead of sudo at the beginning, --user at the end solves the same problem in a much more reponsible way
    – craq
    Sep 17, 2018 at 0:31

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.