平時在下載安裝python庫的時候會發現下載速度特別慢,這時我們就需要使用清華鏡像來助力我們加速該過程,因爲所有文件都是來源於國外服務器,自然下載速度很慢,我們使用清華鏡像的時候需要注意,鏡像不是實時更新的,可能國外最新的是2.0.0版本可能鏡像需要過一段時間纔會更新到該版本,以下會介紹兩種使用清華鏡像的方法
一
舉如下例子
pip install tensorflow -i https://pypi.tuna.tsinghua.edu.cn/simple
或
conda install tensorflow -i https://pypi.tuna.tsinghua.edu.cn/simple
這裏使用的後綴==-i https://pypi.tuna.tsinghua.edu.cn/simple==就是使用清華鏡像下載,不管是什麼庫,都可以使用
當然pip既能在cmd中執行也能在Anaconda Prompt中執行,而conda命令只能在後者中執行
二
(一勞永逸)
進入清華鏡像官網==https://mirrors.tuna.tsinghua.edu.cn/==
找到anaconda,點擊問號
裏面會有使用說明
在此爲了方便大家,就給大家直接說了
Step1:先進入用戶目錄下找到.condarc文件
Windows 用戶無法直接創建名爲 .condarc 的文件,可先執行 conda config --set show_channel_urls yes 生成該文件之後再修改。
Step2:右鍵使用文本文件打開,更改裏面的內容,改爲
channels:
- defaults
show_channel_urls: true
default_channels:
- https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main
- https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free
- https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/r
custom_channels:
conda-forge: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud
msys2: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud
bioconda: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud
menpo: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud
pytorch: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud
simpleitk: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud
後面大家就可以自己試試直接pip install tensorflow 或 conda install tensorflow,
希望能幫到大家