pythonmacospython-2.7pipsix

six cannot be imported/uninstalled/reinstalled/upgraded


I'm trying to run lldb on my MacBook terminal, but I get errors related to the six package:

File "/Applications/Xcode.app/Contents/SharedFrameworks/LLDB.framework/Resources/Python/lldb/__init__.py", line 98, in <module>
    import six
ImportError: No module named six
Traceback (most recent call last):
  File "<string>", line 1, in <module>

I tried to launch python from terminal and then execute import six, but still:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ImportError: No module named six

Next step was to uninstall and reinstall six, but it seems like everything related to this package is corrupted for me:

$: pip uninstall six
Uninstalling six:
  /System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/six-1.4.1-py2.7.egg-info
Proceed (y/n)? y
Exception:
Traceback (most recent call last):
  File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/pip/basecommand.py", line 122, in main
    status = self.run(options, args)
  File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/pip/commands/uninstall.py", line 59, in run
    requirement_set.uninstall(auto_confirm=options.yes)
  File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/pip/req.py", line 1035, in uninstall
    req.uninstall(auto_confirm=auto_confirm)
  File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/pip/req.py", line 598, in uninstall
    paths_to_remove.remove(auto_confirm)
  File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/pip/req.py", line 1836, in remove
    renames(path, new_path)
  File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/pip/util.py", line 295, in renames
    shutil.move(old, new)
  File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/shutil.py", line 302, in move
    copy2(src, real_dst)
  File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/shutil.py", line 131, in copy2
    copystat(src, dst)
  File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/shutil.py", line 103, in copystat
    os.chflags(dst, st.st_flags)
OSError: [Errno 1] Operation not permitted: '/var/folders/_c/lj7t1035563flfh7fy4m3gfh0000gn/T/pip-YQdNMp-uninstall/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/six-1.4.1-py2.7.egg-info'

Storing debug log for failure in /Users/lab5/.pip/pip.log

$: pip install --ignore-installed six
Downloading/unpacking six
  Cannot fetch index base URL https://pypi.python.org/simple/
  Could not find any downloads that satisfy the requirement six
Cleaning up...
No distributions at all found for six
Storing debug log for failure in /Users/lab5/.pip/pip.log

I downloaded six and installed it from the tar.gz file, but it still seems like the old version is installed:

$: pip install --ignore-installed ~/Downloads/six-1.5.1.tar.gz
Unpacking ./Downloads/six-1.5.1.tar.gz
  Running setup.py (path:/var/folders/_c/lj7t1035563flfh7fy4m3gfh0000gn/T/pip-zqLhAa-build/setup.py) egg_info for package from file:///Users/lab5/Downloads/six-1.5.1.tar.gz

    no previously-included directories found matching 'documentation/_build'
Installing collected packages: six
  Running setup.py install for six

    no previously-included directories found matching 'documentation/_build'
Successfully installed six
Cleaning up...

$: pip show six
---
Name: six
Version: 1.4.1
Location: /System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python
Requires:

Python version: Python 2.7.15
Pip version: pip 1.5.6 from /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages (python 2.7)

Do you have any recommendations for me how to get rid of those errors and run lldb properly? I took someone's suggestion to install python again (simply brew install python), but it was not helpful.


Solution

  • I'm still not sure what the reasons for the errors were, but I could get rid of them after upgrading my python version and I'm just fine with that.

    To install a new python version:

    brew install python
    

    Then, I removed the link at /usr/local/bin/python and set it again to the new version:

    rm /usr/local/bin/python
    ln -s /usr/local/Cellar/python/3.7.0/bin/python3.7 /usr/local/bin/python
    

    Then, installed six with the new version's pip:

    python -m pip install six
    

    (executing python -m enforces installing with the new pip, for the new python)

    I'm not 100% cool with that solution, I still have to remove old versions to have a clean python installation, but at least I can work with lldb now, which was my main goal