yetanotherstupiddev
yetanotherstupiddev

Reputation: 23

Installing enum34 on Python 3.x breaks pip for Python3.x

I used PythonAnywhere to host some Python scripts that required the fbchat module. I installed the module on Python 3.6 (with user scheme) without using virtualenv, and the module installed enum34 as a dependency.

I know enum34 is incompatible with Python versions greater than 3.4. However I can't uninstall it now either because calling pip3.x gives this error:

Traceback (most recent call last):
  File "/usr/local/bin/pip3.6", line 4, in <module>
    import re
  File "/usr/lib/python3.6/re.py", line 142, in <module>
    class RegexFlag(enum.IntFlag):
AttributeError: module 'enum' has no attribute 'IntFlag'

and the command $ python3.6 -m pip gives:

Traceback (most recent call last):
  File "/usr/lib/python3.6/runpy.py", line 183, in _run_module_as_main
    mod_name, mod_spec, code = _get_module_details(mod_name, _Error)
  File "/usr/lib/python3.6/runpy.py", line 142, in _get_module_details
    return _get_module_details(pkg_main_name, error)
  File "/usr/lib/python3.6/runpy.py", line 109, in _get_module_details
    __import__(pkg_name)
  File "/usr/local/lib/python3.6/dist-packages/pip/__init__.py", line 4, in <module>
    import locale
  File "/usr/lib/python3.6/locale.py", line 16, in <module>
    import re
  File "/usr/lib/python3.6/re.py", line 142, in <module>
    class RegexFlag(enum.IntFlag):
AttributeError: module 'enum' has no attribute 'IntFlag'

These are the exact steps to reproduce, and the only commands used to get here:

$ pip3.6 install --user fbchat

Upvotes: 2

Views: 2358

Answers (1)

Martijn Pieters
Martijn Pieters

Reputation: 1122182

Just delete the package from your site-packages folder manually.

Locate it first:

python3.6 -c 'import enum; print(enum.__file__)'

then delete the whole enum directory that file lives in, it'll be in a site-packages directory. Delete the enum34-<version>.dist-info file next to it too.

Because you used --user, the package was installed in your user-site directory. You can get the location with the site module too:

python3.6 -m site --user-site

so you can remove the offending package with:

rm -rf `python3.6 -m site --user-site`/enum 
rm `python3.6 -m site --user-site`/enum-*.dist-info

Upvotes: 7

Related Questions