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?
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.
To use the system Python for lldb but keep using Homebrew python for everything else, save this shell script as ~/.local/bin/lldb
:
#!/bin/sh
unset PYTHONPATH
export PATH=/usr/bin:$PATH
exec lldb "$@"
Then chmod +x ~/.local/bin/lldb
to make it executable. Make sure ~/.local/bin
is in your PATH
, and comes before /usr/bin
where the system lldb
lives.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With