首页 > 解决方案 > 如何正确地将“脚本轮”添加到 python 路径?

问题描述

我刚刚从python.org安装了 Python 3.7 。我按照这个StackOverflow 帖子将我的默认 Python 更改为 Python 3。从那里我运行了 Update Shell Profile.command 和 Install Certificates.command(Finder > Applications > Python 3.7)。

然后我发现我无法运行 pip 命令

> $ pip --version

> -bash: pip: command not found

随后我运行了以下2个命令..

> $ curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py
> 
> $ python get-pip.py
Collecting pip
  Downloading https://files.pythonhosted.org/packages/5f/25/e52d3f31441505a5f3af41213346e5b6c221c9e086a166f3703d2ddaf940/pip-18.0-py2.py3-none-any.whl (1.3MB)
    100% |████████████████████████████████| 1.3MB 5.5MB/s 
Collecting wheel
  Downloading https://files.pythonhosted.org/packages/81/30/e935244ca6165187ae8be876b6316ae201b71485538ffac1d718843025a9/wheel-0.31.1-py2.py3-none-any.whl (41kB)
    100% |████████████████████████████████| 51kB 12.1MB/s 
Installing collected packages: pip, wheel
Could not install packages due to an EnvironmentError: [Errno 13] Permission denied: '/Library/Python/2.7/site-packages/pip'
Consider using the `--user` option or check the permissions.

然后我添加了--user标志

> $ python get-pip.py --user
> 
> Collecting pip   Using cached
> https://files.pythonhosted.org/packages/5f/25/e52d3f31441505a5f3af41213346e5b6c221c9e086a166f3703d2ddaf940/pip-18.0-py2.py3-none-any.whl
> Collecting wheel   Using cached
> https://files.pythonhosted.org/packages/81/30/e935244ca6165187ae8be876b6316ae201b71485538ffac1d718843025a9/wheel-0.31.1-py2.py3-none-any.whl
> Installing collected packages: pip, wheel  

这是我不明白的

> The script wheel is
> installed in '/Users/kevinturney/Library/Python/2.7/bin' which is not
> on PATH.   

> Consider adding this directory to PATH or, if you prefer to
> suppress this warning, use --no-warn-script-location.

什么是轮子,如何将其添加到正确的路径?

> $ which python

> /usr/local/opt/python/libexec/bin/python

什么是轮子,如何将其添加到正确的路径?

标签: pythonpath

解决方案


推荐阅读