一、在mac筆記本上安裝python3
brew install python3
二、在mac筆記本上安裝pip3
在做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.3pip3命令依然無法執行。
-
最後,爲在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)