Mac brew更新后 command not found: python

来源:互联网 发布:淘宝买家4心要多少好评 编辑:程序博客网 时间:2024/05/22 00:18

更新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/pip2python2 -> ../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 pipln -s ../Cellar/python/2.7.14/bin/python2 pythonpip -> ../Cellar/python/2.7.14/bin/pip2python -> ../Cellar/python/2.7.14/bin/python2