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
目录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
- Tsinghua - https://pypi.tuna.tsinghua.edu.cn/simple
- Alibaba Cloud - http://mirrors.aliyun.com/pypi/simple/
- University of Science and Technology of China - https://pypi.mirrors.ustc.edu.cn/simple/
- Huazhong University of Science and Technology: http://pypi.hustunique.com/
- Shandong University of Technology: http://pypi.sdutlinux.org/
- Douban: http://pypi.douban.com/simple/
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 yesConfigure 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
- WeChat Official Account: 画星星高手
- Coding livestream: https://live.bilibili.com/11883038
- Zhihu: https://www.zhihu.com/people/dealiaxy
- Blog: https://blog.deali.cn
- Jianshu: https://www.jianshu.com/u/965b95853b9f
_EOF_
Configure pip domestic mirrors to speed up python third-party library installation~
- 本文作者:
- 程序设计实验室
- 版权声明:
- 本博客所有文章除特别声明外,均采用 BY-NC-SA 许可协议。转载请注明出处!
相关文章
后 Django 时代:SQLAlchemy 2.0、Tortoise 与 Piccolo 三大异步 ORM 选型指南
SQLAlchemy 2.0 才是工业级稳定,Alembic 迁移能力谁用谁知道。Tortoise ORM 是 Django 老玩家的舒适区,但灵活度有限。Piccolo 语法现代但生态太嫩,适合玩票。别再迷信 Stars,生产环境看的是谁扛造。
2026-04-10 · Python · 约 1 分钟
Python创建压缩文件
代码实现 # 创建一个目录来保存这些东西 temp_path = os.path.join(settings.MEDIA_ROOT, 'temp', str(uuid.uuid4())) os.makedirs(temp_path) # 创建压缩文件 archive_path = os.path.join(temp_path, 'archive.zip') with zipfile.ZipFile
2022-09-30 · Python · 约 1 分钟
2025年了,在 Django 之外,Python Web 框架还能怎么选?
2025年了,Django之外还剩啥?LiteStar轻量快,Tortoise ORM省心,Granian丢掉Nginx,RobynPython+Rust。独立开发者终于不用被全家桶绑架?
2025-09-14 · Python · 约 1 分钟
使用Python+FFMPEG实现视频分割与合并
前言 日常中偶尔会遇到需要简单剪辑处理视频的场景,以前我可能会拿出PR来剪辑一下,(别跟我说国产那些软件,剪辑完视频强制加上广告片头片尾恶心的一批),但是PR毕竟太重量级,剪个简单的视频都要花不少时间,直到我发现了FFmpeg…… 这个FFmpeg真的是神器,免费开源功能强大,好像很多软件都是基于这个开发的,它本身提供了命令行接口就已经能满足我们日常的简单视频处理需求,我用来简单处理视频分割、合并
2022-05-27 · Python · 约 1 分钟
讨论
共 0 条加载评论中…