Xcode启动失败,提示"Loading a plug-in failed The plug-in or one of its prerequisite plug-ins may be missin

学习机器学习,搭建环境时,把系统默认的python 2.7升级到3.6版,又删除了2.7。再打开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
根据提示,说要重新安装Xcode,网速太慢,重新安装不靠谱。
使用命令行查看错误消息

$/Applications/Xcode.app/Contents/MacOS/Xcode

错误

Library not loaded: /System/Library/Frameworks/Python.framework/Versions/2.7/Python

说明错误是因为python,不是系统自带版本,缺少了很多第三方lib。重新安装2.7还是有问题。

解决方案

获取到系统自带的/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

修改环境变量等一定要备份,
这是我参考的大神的文章,学到很多。
https://blog.csdn.net/fenghuangjc/article/details/82761302

你可能感兴趣的:(Xcode启动失败,提示"Loading a plug-in failed The plug-in or one of its prerequisite plug-ins may be missin)