pip install命令安裝擴展庫整理

pip install命令用於安裝擴展庫,由於安裝擴展庫需要從國外網站下載,速度較慢,可以使用-i選項設置臨時使用國內的鏡像網站。

命令格式:

pip install -i 鏡像地址 包名
例如:
pip install -i http://pypi.douban.com/simple/ django

常用國內鏡像地址:

清華大學:https://pypi.tuna.tsinghua.edu.cn/simple/
阿裡雲:https://mirrors.aliyun.com/pypi/simple/
豆瓣網:https://pypi.douban.com/simple/
中國科技大學:https://pypi.mirrors.ustc.edu.cn/simple/

使用pip install命令時,如果出現“WARNING: The repository located at pypi.douban.com is not a trusted or secure host and is being ignored. If this repository is available via HTTPS we recommend you use HTTPS instead, otherwise you may silence this warning and allow it anyway with ‘–trusted-host pypi.douban.com’.”安裝錯誤問題:

在這裡插入圖片描述

解決辦法:

(1)可以使用參數–trusted-host指定可信任的主機
pip install -i http://pypi.douban.com/simple django –trusted-host=pypi.douban.com

在這裡插入圖片描述

安裝成功後,可以用pip list查看包列表驗證一下。

在這裡插入圖片描述

(2)不用參數–trusted-host,把http換成https。
pip install -i https://pypi.douban.com/simple django

試一下,先刪除已安裝的django包
pip uninstall django

在這裡插入圖片描述
在這裡插入圖片描述

安裝成功。

到此這篇關於pip install命令安裝擴展庫整理的文章就介紹到這瞭,更多相關pip install命令內容請搜索WalkonNet以前的文章或繼續瀏覽下面的相關文章希望大傢以後多多支持WalkonNet!

推薦閱讀: