$ brew install python3
提示:
Error: Can't create update lock in /usr/local/var/homebrew/locks!
Fix permissions by running:
sudo chown -R $(whoami) /usr/local/var/homebrew
Error: Permission denied - /usr/local/var/homebrew/locks/python3.brewing
执行如下:
$sudo chown -R $(whoami) /usr/local/var/homebrew
$ which python3
终端输出
/usr/local/bin/python3
上面方法没解决参考下面链接安装3.0以上版本:
https://www.jianshu.com/p/f44cb9328d46
安装上面会出现路径不对的问题,
需求改下
$which pip3
/System/Library/Frameworks/Python.framework/Versions/3.7/bin/pip3
$sudo vim /System/Library/Frameworks/Python.framework/Versions/3.7/bin/pip3
把!#后的路径改成上面which pip3输出的路径即可
查看是pip否安装好了,输入如下命令能否看到用法说明
$pip
$pip3
如输入pip提示下面信息,则是版本号不对,输入pip3查看版本,修改/user/local/bin/pip文件里对应的版本号
Traceback (most recent call last):
File "/usr/local/bin/pip", line 5, in <module>
from pkg_resources import load_entry_point
File "/System/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/pkg_resources/__init__.py", line 3191, in <module>
参照上面链接安装会导致xcode不能用,报错,网上有建议不要删除系统的python2.7;如果已经删了,则重新装回:
$brew install python@2