pip國內源配置
阿新 • • 發佈:2022-05-12
Python 的一大優點就是豐富的類庫,所以我們經常會用 pip 來安裝各種庫,所以對於Python開發使用者來講,PIP安裝軟體包是家常便飯。但國外的源下載速度實在太慢,浪費時間。而且經常出現下載後安裝出錯問題。所以把PIP替換為國內源,可以大幅提升下載速度,還可以提高安裝成功率。
一、將pip修改為pip國內源即可
pip和很多的包管理工具一樣,是從國外源下載的。因此速度會比較慢,甚至會安裝不了
清華:https://pypi.tuna.tsinghua.edu.cn/simple 阿里雲:https://mirrors.aliyun.com/pypi/simple/ 中國科技大學:https://pypi.mirrors.ustc.edu.cn/simple/
二、臨時修改
可以在使用pip的時候加引數 -i https://pypi.tuna.tsinghua.edu.cn/simple
pip install pycrytodome -i https://pypi.tuna.tsinghua.edu.cn/simple
這樣就會從清華映象庫去安裝pycrytodome庫
三、永久修改
liunx系統
vim ~/.pip/pip.conf
[global]
index-url = https://pypi.tuna.tsinghua.edu.cn/simple
window系統
在user目錄中建立一個pip目錄,如:C:Userspip,新建檔案pip.ini,新增一下內容
[global]
index-url = https://pypi.tuna.tsinghua.edu.cn/simple