安裝pip


  使用pip可以很方便地安裝所需的python包,本篇僅簡單記錄下pip的安裝,以備日后查閱。

1、下載get-pip.py

  get-pip.py下載地址:https://bootstrap.pypa.io/get-pip.py

2、安裝

  我是將這個腳本放在Python的安裝路徑的Scripts目錄下:

C:\Python27\Scripts>python get-pip.py
Collecting pip
  Using cached https://files.pythonhosted.org/packages/5f/25/e52d3f31441505a5f3af41213346e5b6c221c9e086a166f3703d2ddaf940/pip-18.0-py2.py3-none-any.whl
Collecting wheel
  Downloading https://files.pythonhosted.org/packages/81/30/e935244ca6165187ae8be876b6316ae201b71485538ffac1d718843025a9/wheel-0.31.1-py2.py3-none-any.whl (41kB)
    100% |████████████████████████████████| 51kB 624kB/s
Installing collected packages: pip, wheel
  Found existing installation: pip 9.0.3
    Uninstalling pip-9.0.3:
      Successfully uninstalled pip-9.0.3
  The script wheel.exe is installed in 'C:\Python27\Scripts' 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.0 wheel-0.31.1

  默認會在當前目錄生成幾個pip*.exe,也即是:C:\Python27\Scripts

 C:\Python27\Scripts 的目錄

2018/08/18  11:13    <DIR>          .
2018/08/18  11:13    <DIR>          ..
2018/08/18  11:13           102,752 chardetect.exe
2018/07/27  13:17            98,153 easy_install-2.7.exe
2018/07/27  13:17            98,153 easy_install.exe
2018/08/10  15:22         1,642,522 get-pip.py
2018/08/10  15:23           102,743 pip.exe 2018/08/10  15:23           102,743 pip2.7.exe 2018/08/10  15:23           102,743 pip2.exe 2018/08/10  15:23           102,740 wheel.exe
               8 個文件      2,352,549 字節
               2 個目錄 183,052,087,296 可用字節

  需要將pip的文件的路徑加到環境變量中,這樣在其他目錄下也能使用pip命令:

  步驟:右鍵我的電腦->屬性->高級系統設置->高級選項卡->環境變量->系統變量->Path->加入pip所在路徑:C:\Python27\Scripts,

       

3、安裝python包

  上面安裝好pip之后,就可以使用pip install命令安裝我們所需要的包了。

C:\Python27\Scripts>pip install dnspython gevent
Collecting dnspython
  Downloading https://files.pythonhosted.org/packages/a6/72/209e18bdfedfd78c6994e9ec96981624a5ad7738524dd474237268422cb8/dnspython-1.15.0-py2.py3-none-any.whl (177kB)
    100% |████████████████████████████████| 184kB 758kB/s
Collecting gevent
  Downloading https://files.pythonhosted.org/packages/f1/54/61ae4d9e1078c52047fa625cf39c8197517baa45599174e5d3ed91105b8a/gevent-1.3.5-cp27-cp27m-win_amd64.whl (2.1MB)
    100% |████████████████████████████████| 2.1MB 3.2MB/s
Collecting cffi>=1.11.5; sys_platform == "win32" and platform_python_implementation == "CPython" (from gevent)
  Downloading https://files.pythonhosted.org/packages/89/12/684bad296567b9300c7ac82a4f635b489ed589fa7c0bb2042208e3c020e3/cffi-1.11.5-cp27-cp27m-win_amd64.whl (163kB)
    100% |████████████████████████████████| 163kB 957kB/s
Collecting greenlet>=0.4.13; platform_python_implementation == "CPython" (from gevent)
  Downloading https://files.pythonhosted.org/packages/ad/23/1a05344026d49ba6a685ebad19933cdae0ef133038da5a941bfe2b215a6d/greenlet-0.4.14-cp27-cp27m-win_amd64.whl
Collecting pycparser (from cffi>=1.11.5; sys_platform == "win32" and platform_python_implementation == "CPython"->gevent)
  Downloading https://files.pythonhosted.org/packages/8c/2d/aad7f16146f4197a11f8e91fb81df177adcc2073d36a17b1491fd09df6ed/pycparser-2.18.tar.gz (245kB)
    100% |████████████████████████████████| 256kB 1.3MB/s
Building wheels for collected packages: pycparser
  Running setup.py bdist_wheel for pycparser ... done
  Stored in directory: C:\Users\liuzhen\AppData\Local\pip\Cache\wheels\c0\a1\27\5ba234bd77ea5a290cbf6d675259ec52293193467a12ef1f46
Successfully built pycparser
Installing collected packages: dnspython, pycparser, cffi, greenlet, gevent
Successfully installed cffi-1.11.5 dnspython-1.15.0 gevent-1.3.5 greenlet-0.4.14 pycparser-2.18


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM