今天我用爬虫时,把python升级到3.6版。再打开Xcode时提示报错:Loading a plug-in failed The plug-in or one of its prerequisite plug-ins may be missing or damaged and may need to be reinstalled
使用命令行查看错误消息
$/Applications/Xcode.app/Contents/MacOS/Xcode
错误
Library not loaded: /System/Library/Frameworks/Python.framework/Versions/XXX/Python,
说明错误是因为python,不是系统自带版本,缺少了很多第三方lib。
解决方案
获取到系统自带的/Library/Frameworks/Python.framework/Versions/2.7
,可以从其它电脑拷贝,替换到原来的位置。
1.修改配置
sudo chown -R root:wheel /System/Library/Frameworks/Python.framework/Versions/2.7
sudo rm /System/Library/Frameworks/Python.framework/Versions/Current
sudo ln -s /System/Library/Frameworks/Python.framework/Versions/2.7 /System/Library/Frameworks/Python.framework/Versions/Current
2.重新链接可执行文件
sudo rm /usr/bin/pydoc
sudo rm /usr/bin/python
sudo rm /usr/bin/pythonw
sudo rm /usr/bin/python-config
3.建立新的链接
sudo ln -s /System/Library/Frameworks/Python.framework/Versions/2.7/bin/pydoc2.7 /usr/bin/pydoc
sudo ln -s /System/Library/Frameworks/Python.framework/Versions/2.7/bin/python2.7 /usr/bin/python
sudo ln -s /System/Library/Frameworks/Python.framework/Versions/2.7/bin/pythonw2.7 /usr/bin/pythonw
sudo ln -s /System/Library/Frameworks/Python.framework/Versions/2.7/bin/python2.7m-config /usr/bin/python-config
注:
最后还可以vi ~/.bash_profile
进行编辑
# Setting PATH for Python 2,7
# The orginal version is saved in .bash_profile.pysave
PATH="/System/Library/Frameworks/Python.framework/Versions/2.7/bin:${PATH}"
export PATH