Homebrew – Fix ImportError and NameErrors Running LLDB with HomeBrew Python 2

homebrewmacospythonterminal

I had upgraded vim with HomeBrew to version 7.4.1952 on OS X 10.11.6. It installed python 2 as a dependency package (Summarized parts of output is shown by ...):

$ brew upgrade vim
...
==> Installing vim dependency: python
?   /usr/local/Cellar/python/2.7.11: 4,949 files, 66.6M
...

Now when I try to run lldb, it produces ImportError and NameErrors:

$ lldb myExecutableFile
Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "/Applications/Xcode.app/Contents/SharedFrameworks/LLDB.framework/Resources/Python/lldb/__init__.py", line 98, in <module>
    import six
ImportError: No module named six
(lldb) target create "myExecutableFile"
Traceback (most recent call last):
  File "<string>", line 1, in <module>
NameError: name 'run_one_line' is not defined
Traceback (most recent call last):
  File "<string>", line 1, in <module>
NameError: name 'run_one_line' is not defined
...
Current executable set to 'myExecutableFile' (x86_64).
(lldb)

This is my $PATH in zsh shell:

/usr/local/sbin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin

How can I solve these errors?

Best Answer

I installed six module with pip python package manager and it solves the problem:

$ pip install six
Collecting six
  Using cached six-1.10.0-py2.py3-none-any.whl
Installing collected packages: six
Successfully installed six-1.10.0

$ lldb myExecutableFile
(lldb) target create "myExecutableFile"
Current executable set to 'myExecutableFile' (x86_64).
(lldb)