brew install python3
在做Python开发时,通常需要使用pip3进行进行其他Python包的安装,默认是Python3自带了pip3,但是通常不能够直接启动pip3,所以需要手动来进行pip3的安装,步骤如下:
首先,进入下面链接,下载需要的Python脚本文件:
执行命令:
curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py
下载得到 get-pip.py
文件。
其次,执行 get-pip.py
文件脚本:
python3 get-pip.py
Collecting pip
Using cached https://files.pythonhosted.org/packages/c2/d7/90f34cb0d83a6c5631cf71dfe64cc1054598c843a92b400e55675cc2ac37/pip-18.1-py2.py3-none-any.whl
Collecting setuptools
Downloading https://files.pythonhosted.org/packages/e7/16/da8cb8046149d50940c6110310983abb359bbb8cbc3539e6bef95c29428a/setuptools-40.6.2-py2.py3-none-any.whl (573kB)
100% |████████████████████████████████| 573kB 639kB/s
Collecting wheel
Downloading https://files.pythonhosted.org/packages/ff/47/1dfa4795e24fd6f93d5d58602dd716c3f101cfd5a77cd9acbe519b44a0a9/wheel-0.32.3-py2.py3-none-any.whl
Installing collected packages: pip, setuptools, wheel
The script wheel is installed in ‘/usr/local/Cellar/python3/3.6.4_2/Frameworks/Python.framework/Versions/3.6/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.
Successfully installed pip-18.1 setuptools-40.6.2 wheel-0.32.3
pip3命令依然无法执行。
最后,为在python 3的Frameworks目录下的bin目录下进行pip3在mac上建立软链:
ln -s /usr/local/Cellar/python3/3.6.4_2/Frameworks/Python.framework/Versions/3.6/bin/pip3 /usr/local/bin/
这里的 /usr/local/Cellar/python3/3.6.4_2/Frameworks/Python.framework/Versions/3.6/bin/pip3
需要根据自己的电脑环境进行指定。
之后执行命令验证pip3正确安装:
pip3 -V
pip 18.1 from /usr/local/Cellar/python3/3.6.4_2/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/pip (python 3.6)