执行pip3命令,提示:zsh: /usr/local/bin/pip3: bad interpreter: /Library/Developer/CommandLineTools/usr/bin/python3: no such file or directory
执行pip3安装命令,提示:Defaulting to user installation because normal site-packages is not writeable
如图
原因:python路径不正确
方法
➜ which python3
/usr/bin/python
➜ cd /usr/local/bin
➜ bin vim pip3
修改第一行为which python3的结果
#!/Library/Developer/CommandLineTools/usr/bin/python3 # -*- coding: utf-8 -*- import re import sys from pip._internal.cli.main import main if __name__ == '__main__': sys.argv[0] = re.sub(r'(-script\.pyw?|\.exe)?$', '', sys.argv[0]) sys.exit(main())
如下:
#!/usr/bin/python3 # -*- coding: utf-8 -*- import re import sys from pip._internal.cli.main import main if __name__ == '__main__': sys.argv[0] = re.sub(r'(-script\.pyw?|\.exe)?$', '', sys.argv[0]) sys.exit(main())
再次执行pip3命令,无报错。