Search code examples
macosmacos-sierralldb

Getting _remove_dead_weakref error for LLDB


Everytime I launch lldb on MacOS, I'm getting the following error.

  File "<input>", line 1, in <module>
  File "/usr/local/Cellar/python@2/2.7.15_1/Frameworks/Python.framework/Versions/2.7/lib/python2.7/copy.py", line 52, in <module>
    import weakref
  File "/usr/local/Cellar/python@2/2.7.15_1/Frameworks/Python.framework/Versions/2.7/lib/python2.7/weakref.py", line 14, in <module>
    from _weakref import (
ImportError: cannot import name _remove_dead_weakref

I checked that all the files and names were there.

I don't know what's causing this problem.

Any ideas?


Solution

  • The Python framework lldb uses actually comes with the system, not with Xcode, but other than that, Brad's onto it.

    lldb links to Python, which it uses to power a bunch of extensibility features. Even though lldb pulls in the Python dylib from the system install - because that's what it linked to - the presence of other Pythons (usually found because the other python binary is on your path ahead of /usr/bin/python) will cause Python to read its library files from the other Python install. And that seems not to go well in general.

    In most of the cases where we've seen this, making sure /usr/bin/python is frontmost on your path will solve the issue. Also make sure PYTHONPATH doesn't refer to the python files in your side installation.