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命令內容請搜索腳本之家以前的文章或繼續瀏覽下面的相關文章希望大家以后多多支持腳本之家!
您可能感興趣的文章:- 用pip給python安裝matplotlib庫的詳細教程
- pip 20.3 新版本發布!即將拋棄 Python 2.x(推薦)
- python subprocess pipe 實時輸出日志的操作
- Python更改pip鏡像源的方法示例
- Python離線安裝各種庫及pip的方法