我试图在MacBook终端上运行lldb
,但是遇到与six
软件包有关的错误:
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>
我尝试从终端启动python,然后执行import six
,但仍然:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: No module named six
下一步是卸载并重新安装six
,但似乎与此软件包相关的所有内容对我来说都已损坏:
$: 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
我下载了six
并从tar.gz文件中安装了它,但看起来仍然好像安装了旧版本:
$: 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)
您对我有什么建议,如何消除这些错误并正确运行lldb
?我接受了某人的建议再次安装python(仅brew install python
),但这没有帮助。
答案 0 :(得分:0)
您正在使用python2,要使用brew安装python2,您需要添加@2
brew install python@2
我使用brew随附安装的python2并能够安装六个。根据您的错误,当您尝试pip install six
时,它会显示OSError: [Errno 1] Operation not permitted:
尝试使用sudo -H
sudo -H pip install six --upgrade
答案 1 :(得分:0)
我仍然不确定错误的原因是什么,但是在升级python版本后我可以摆脱它们,我对此表示满意。
要安装新的python版本:
brew install python
然后,我删除了/usr/local/bin/python
上的链接,并将其重新设置为新版本:
rm /usr/local/bin/python
ln -s /usr/local/Cellar/python/3.7.0/bin/python3.7 /usr/local/bin/python
然后用新版本的pip安装six
:
python -m pip install six
(对于新的python,执行python -m
强制使用新的pip进行安装)
该解决方案并非100%不错,我仍然必须删除旧版本以进行全新的python安装,但是至少我现在可以使用lldb
,这是我的主要目标
答案 2 :(得分:0)
使用xcode-select -switch
指向正确的Xcode安装为我解决了。