Mac brew更新后 command not found: python

更新Homebrew

brew upgrade

Python2.7.10升级到Python2.7.14
结果在命令行输入python后,显示

command not found: python

探究原因,发现是因为使用brew安装的python更新为python2(在电脑中已安装python3),输入python2可以进入python。进入/usr/local/bin/目录,发现下列已变更为python2。

pip2 -> ../Cellar/python/2.7.14/bin/pip2
python2 -> ../Cellar/python/2.7.14/bin/python2```

需要我们使用 ln 命令建立python2的连接。

ln [-bfis] existing-file-list(source) new-link
-b    如果需要创建的目标链接已存在相同文件名,则备份
-f    强制创建目标链接
-i    覆盖相同文件名时提示
-s    创建符号链接

建立链接后,输入python也能跳转到python2。

ln -s ../Cellar/python/2.7.14/bin/pip2 pip
ln -s ../Cellar/python/2.7.14/bin/python2 python
pip -> ../Cellar/python/2.7.14/bin/pip2
python -> ../Cellar/python/2.7.14/bin/python2
最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容