ImportError: cannot import name MAXREPEAT

Hi,

I have a new version of python installed. When I start lldb, I see the
following error. Does anybody how to fix the problem while still keep
/Library/Frameworks/Python.framework/Versions/2.7/bin/python as the
default python? Thanks.

~/linux/test/cpp/gdb/deref$ cd
~$ which python
/Library/Frameworks/Python.framework/Versions/2.7/bin/python
~$ lldb
Traceback (most recent call last):
  File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site.py",
line 563, in <module>
    main()
  File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site.py",
line 545, in main
    known_paths = addusersitepackages(known_paths)
  File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site.py",
line 278, in addusersitepackages
    user_site = getusersitepackages()
  File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site.py",
line 253, in getusersitepackages
    user_base = getuserbase() # this will also set USER_BASE
  File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site.py",
line 243, in getuserbase
    USER_BASE = get_config_var('userbase')
  File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/sysconfig.py",
line 472, in get_config_var
    return get_config_vars().get(name)
  File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/sysconfig.py",
line 405, in get_config_vars
    import re
  File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/re.py",
line 105, in <module>
    import sre_compile
  File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/sre_compile.py",
line 14, in <module>
    import sre_parse
  File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/sre_parse.py",
line 17, in <module>
    from sre_constants import *
  File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/sre_constants.py",
line 18, in <module>
    from _sre import MAXREPEAT
ImportError: cannot import name MAXREPEAT

Caveat: it is not really supported to use LLDB with anything but the Python that ships with OSX
FYI: this is the most commonly seen symptom of changing your Python and then using LLDB - the MAXREPEAT must be some awkward piece of Python magic :slight_smile:

Given the above, what follows is totally untested, and might be significantly off track, but did you check whether your PYTHON_PATH matches your custom Python install? That, and does your Current symlink in Python.framework correctly match your installed Python?
Also, it looks like this code is trying to figure out a USER_BASE variable right before failing… I would google for that and see what it is, what it does, and how you can set it up correctly for a custom Python build.

Good luck!

  • Enrico