Solvedhomebrew core "module 'enum' has no attribute 'IntFlag'" when installing python3

  • Ran brew update and retried your prior step?
  • Ran brew doctor, fixed as many issues as possible and retried your prior step?
  • Confirmed this is problem with specific formulae and not Homebrew/brew? If it's a general Homebrew/brew problem please file this issue at https://github.com/Homebrew/brew/issues/new

I am running OS X 10.10.5 with Python 2 installed via Homebrew, chosen as the default. I'm trying to install Python 3 alongside it:

brew install python3

I get the following error:

==> /usr/local/Cellar/python3/3.6.0/bin/python3 -s setup.py --no-user-cfg install --force --verbose --install-scripts=/usr/local/Cellar/python3/3.6.0/bin --in
Last 15 lines from /Users/werner/Library/Logs/Homebrew/python3/post_install.01.python3:
--record=installed.txt

Failed to import the site module
Traceback (most recent call last):
  File "/usr/local/lib/python2.7/site-packages/site.py", line 75, in <module>
    __boot()
  File "/usr/local/lib/python2.7/site-packages/site.py", line 27, in __boot
    import imp # Avoid import loop in Python >= 3.3
  File "/usr/local/Cellar/python3/3.6.0/Frameworks/Python.framework/Versions/3.6/lib/python3.6/imp.py", line 27, in <module>
    import tokenize
  File "/usr/local/Cellar/python3/3.6.0/Frameworks/Python.framework/Versions/3.6/lib/python3.6/tokenize.py", line 33, in <module>
    import re
  File "/usr/local/Cellar/python3/3.6.0/Frameworks/Python.framework/Versions/3.6/lib/python3.6/re.py", line 142, in <module>
    class RegexFlag(enum.IntFlag):
AttributeError: module 'enum' has no attribute 'IntFlag'

My logs are here: https://gist.github.com/slhck/f0321cad507d081aee7e753f531964c8

I am assuming this should work with which python pointing to Python installed via Homebrew?

My $PYTHONPATH is set to /usr/local/lib/python2.7/site-packages: — also not sure if this is expected behavior. I don't remember setting it anywhere and none of my shell config files have it.

Same problem is mentioned here without a solution.

21 Answers

✔️Accepted Answer

@deering59 Make sure that nowhere in your shell configuration files, PYTHONPATH is set to point to your Python 2.7 installation. You can check its current value with echo $PYTHONPATH – for me it's now empty.

Other Answers:

More Issues: