返回文章列表文章索引阅读全文
STARBLOG / 阅读手记
Python

Configure pip domestic mirrors to speed up python third-party library installation~

The network these days is a bit unfriendly for developers, downloading anything is slow, pip install is slow, git clone is slow too, so frustrating... Fortunately there are various alternative domestic mirror sources that can speed things up Temporary configuration When using pip, add the parameter -i https://pypi.tuna.tsinghua.edu.cn/simple For example: pip install -i https://pypi.tuna.tsinghua.edu.cn/simple d

曦远 (DealiAxy)约 10 分钟
目录7 个章节

The network these days is a bit unfriendly for developers, downloading anything is slow, pip install is slow, git clone is slow too, so frustrating...

Fortunately there are various alternative domestic mirror sources that can speed things up

Temporary Configuration

When using pip, add the parameter -i https://pypi.tuna.tsinghua.edu.cn/simple For example: pip install -i https://pypi.tuna.tsinghua.edu.cn/simple django, this will install the django library from Tsinghua's mirror, and it will be much faster.

Persistent Configuration

By modifying the configuration file, you can make pip use the specified mirror source every time you install.

Linux

On Linux, modify ~/.pip/pip.conf (if the path doesn't exist, you need to create the folder and file yourself) The content is as follows:

[global]
index-url = http://mirrors.aliyun.com/pypi/simple/
[install]
trusted-host=mirrors.aliyun.com

Windows

Windows configuration is a bit different from Linux. Just create a pip directory in the user directory, then create a new file pip.ini. (For example: C:\Users\Administrator\pip\pip.ini) The content is the same as above.

Common Domestic Mirror Sources

Anaconda Configuration

Modify the ~/.condarc file

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/r
  - https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/msys2
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
  pytorch-lts: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud
  simpleitk: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud
  # 如果需要使用其他第三方源(参考上方完整列表)
  # 例如 conda install -c pytorch-test,则可以添加
  #pytorch-test: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud

Reference - https://mirrors.tuna.tsinghua.edu.cn/help/anaconda/

The following is the old version

Configure USTC source

conda config --add channels https://mirrors.ustc.edu.cn/anaconda/pkgs/free/  
conda config --set show_channel_urls yes

Configure Tsinghua University source

conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main/
conda config --set show_channel_urls yes

If a mirror source website goes down, when switching sources remember to go to the user directory and delete the original Tsinghua mirrors under the .condarc folder.

About

_EOF_

Configure pip domestic mirrors to speed up python third-party library installation~

本文作者:
程序设计实验室
版权声明:
本博客所有文章除特别声明外,均采用 BY-NC-SA 许可协议。转载请注明出处!

相关文章

使用Python+FFMPEG实现视频分割与合并

前言 日常中偶尔会遇到需要简单剪辑处理视频的场景,以前我可能会拿出PR来剪辑一下,(别跟我说国产那些软件,剪辑完视频强制加上广告片头片尾恶心的一批),但是PR毕竟太重量级,剪个简单的视频都要花不少时间,直到我发现了FFmpeg…… 这个FFmpeg真的是神器,免费开源功能强大,好像很多软件都是基于这个开发的,它本身提供了命令行接口就已经能满足我们日常的简单视频处理需求,我用来简单处理视频分割、合并

2022-05-27 · Python · 约 1 分钟

讨论

共 0 条

良言一句三冬暖,恶语伤人六月寒。

加载评论中…