Managing and Switching PyPI Mirrors with the Oh My Zsh pypi Plugin
This guide explains how to use the Oh My Zsh pypi plugin to list, switch, and test various PyPI mirror sources, improving package download speeds for developers, especially those in mainland China, by providing simple CLI commands and connectivity checks.
Choosing an appropriate PyPI mirror can significantly improve package download speed, especially for users in China where network latency may be high. This article introduces the pypi plugin designed for Oh My Zsh users, which offers commands to list, switch, and test PyPI mirrors.
Plugin Overview
The pypi plugin is a lightweight yet powerful tool that adds a set of commands to Oh My Zsh, allowing quick switching between different PyPI mirror sources and testing their connectivity.
Installation Steps
Install via Git
Open a terminal and clone the plugin repository into the custom plugins directory of Oh My Zsh:
git clone https://github.com/belingud/pypi ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/pypiEdit the ~/.zshrc file and add pypi to the plugins list: plugins=(... pypi ...) Save the file and reload the Zsh configuration:
source ~/.zshrcHow to Use
After installation, the following commands are available:
List Available Mirrors
Run pypi list to display all supported PyPI mirrors and their URLs.
pypi listSwitch to a Specific Mirror
Use pypi use <shortname>, where <shortname> is the alias of the desired mirror (e.g., aliyun for Alibaba Cloud):
pypi use aliyunTest Mirror Connectivity
Verify a mirror's availability with pypi ping <shortname|url>. You can provide either the alias or the full URL: pypi ping tsinghua or
pypi ping https://pypi.org/simple/Supported Mirror List
pypi: https://pypi.org/simple/
aliyun 阿里云
tencent 腾讯
huawei 华为
163 网易
volces 火山
cernet 中国教科研网校园联合镜像站
tsinghua 清华大学
sustech 南方科技大学
bfsu 北京外国语大学
nju 南京大学
dnui 大连东软信息学院
pku 北京大学
njtech 南京工业大学
nyist 南阳理工
sjtu 上海交大
zju 浙江大学
jlu 吉林大学
testpypiMirrors that are only accessible within a campus intranet are not supported.
Precautions
Ensure the short name you provide when switching mirrors is valid.
Use the ping command to check reachability before switching to a new mirror.
Getting Help
For detailed usage of each command, add -h or --help to the command, e.g.:
pypi use -hConclusion
The pypi plugin makes managing and switching PyPI mirrors straightforward. For more information or issues, visit the plugin's GitHub repository.
Signed-in readers can open the original source through BestHub's protected redirect.
This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactand we will review it promptly.
Python Programming Learning Circle
A global community of Chinese Python developers offering technical articles, columns, original video tutorials, and problem sets. Topics include web full‑stack development, web scraping, data analysis, natural language processing, image processing, machine learning, automated testing, DevOps automation, and big data.
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.
