cnpip


Namecnpip JSON
Version 1.2.0 PyPI version JSON
download
home_pagehttps://github.com/caoergou/cnpip
Summary帮助中国用户快速切换 pip 镜像源,提升下载速度的命令行工具.
upload_time2024-12-17 09:50:29
maintainerNone
docs_urlNone
authorcaoergou
requires_python>=3.7
licenseNone
keywords pip mirror chinese speed cli
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # cnpip

![PyPI](https://img.shields.io/pypi/v/cnpip)
![PyPI - Downloads](https://img.shields.io/pypi/dm/cnpip)
![License](https://img.shields.io/github/license/caoergou/cnpip)

`cnpip` 是一个帮助你快速切换 `pip` 镜像源,提升 Python 包的下载速度的命令行工具。  
它可以测试各镜像源的连接速度,并**自动选择最快的镜像源**。

## 快速使用

运行以下命令,快速切换为最快的镜像源:

```bash
pip install cnpip
cnpip set
```

## 功能

- **列出并测试镜像源速度**,按连接速度排序
- **快速切换 pip 镜像源**,支持*手动选择*或*自动选择*最快镜像

## 支持的镜像源

- [清华大学 TUNA](https://pypi.tuna.tsinghua.edu.cn/simple)
- [中国科学技术大学 USTC](https://pypi.mirrors.ustc.edu.cn/simple)
- [阿里云 Aliyun](https://mirrors.aliyun.com/pypi/simple)
- [腾讯 Tencent](https://mirrors.cloud.tencent.com/pypi/simple)
- [华为 Huawei](https://repo.huaweicloud.com/repository/pypi/simple)
- [默认源 PyPi](https://pypi.org/simple)

## 使用方法

### 1. 列出所有可用的镜像源

```bash
cnpip list
```

示例输出:

```
镜像名称       耗时(ms)     地址
--------------------------------------------------
ustc         135.71       https://pypi.mirrors.ustc.edu.cn/simple
aliyun       300.77       https://mirrors.aliyun.com/pypi/simple
tuna         499.51       https://pypi.tuna.tsinghua.edu.cn/simple
default      1252.75      https://pypi.org/simple
tencent      1253.07      https://mirrors.cloud.tencent.com/pypi/simple
```

### 2. 自动选择最快的镜像源

```bash
cnpip set
```

示例输出:

```
未指定镜像源,自动选择最快的镜像源: ustc
成功设置 pip 镜像源为 'https://pypi.mirrors.ustc.edu.cn/simple'
```

### 3. 选择指定的镜像源

```bash
cnpip set <镜像名称>
```

示例:

```bash
cnpip set tuna
```

输出:

```
成功设置 pip 镜像源为 'https://pypi.tuna.tsinghua.edu.cn/simple'
```

### 4. 取消自定义镜像源设置

```bash
cnpip unset
```

输出:

```
成功取消 pip 镜像源设置,已恢复为默认源。
```

## 配置文件

`cnpip` 会修改或创建 `pip` 的配置文件来设置镜像源:

- **Linux/macOS**: `~/.pip/pip.conf`
- **Windows**: `%APPDATA%\pip\pip.ini`

在设置镜像源时,`cnpip` 只会修改或添加 `index-url` 配置,不会覆盖其他配置项。

## 常见问题

### 1. 为什么我无法连接到某些镜像源?

某些镜像源(如豆瓣)可能由于网络问题或镜像源本身的原因无法连接。在这种情况下,`cnpip` 会显示“无法连接”,并将其排在速度测试结果的最后。

### 2. 如何恢复为默认的 `pip` 镜像源?

使用 `unset` 命令恢复为默认的 `pip` 镜像源:

```bash
cnpip unset
```

### 3. `cnpip` 会覆盖我的 `pip.conf` 文件吗?

不会。`cnpip` 只会修改或添加 `index-url` 配置项,其他配置项会被保留。

## 许可证

本项目使用 [MIT 许可证](LICENSE)。

---

# cnpip (English)

`cnpip` is a command-line tool designed specifically for users in **mainland China** to help quickly switch `pip`
mirrors and improve Python package download speeds.       
It tests the connection speed of various mirrors and **automatically selects the fastest one**.

> **Attention: This Python package is only available in Chinese mainland.**

## Quick Start

Run the following commands to quickly switch to the fastest mirror:

```bash
pip install cnpip
cnpip set
```

## Features

- **List and test mirror speeds**, sorted by connection time
- **Quickly switch pip mirrors**, supporting *manual selection* or *automatic selection* of the fastest mirror
- Designed specifically for users in mainland China

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/caoergou/cnpip",
    "name": "cnpip",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.7",
    "maintainer_email": null,
    "keywords": "pip, mirror, Chinese, speed, cli",
    "author": "caoergou",
    "author_email": "caoergou <mrjingcheng@foxmail.com>",
    "download_url": "https://files.pythonhosted.org/packages/2f/53/8073c621b1855e51ea7494bd38adcf4ec3d8b4b2925ca5891c773bdcd982/cnpip-1.2.0.tar.gz",
    "platform": null,
    "description": "# cnpip\n\n![PyPI](https://img.shields.io/pypi/v/cnpip)\n![PyPI - Downloads](https://img.shields.io/pypi/dm/cnpip)\n![License](https://img.shields.io/github/license/caoergou/cnpip)\n\n`cnpip` \u662f\u4e00\u4e2a\u5e2e\u52a9\u4f60\u5feb\u901f\u5207\u6362 `pip` \u955c\u50cf\u6e90\uff0c\u63d0\u5347 Python \u5305\u7684\u4e0b\u8f7d\u901f\u5ea6\u7684\u547d\u4ee4\u884c\u5de5\u5177\u3002  \n\u5b83\u53ef\u4ee5\u6d4b\u8bd5\u5404\u955c\u50cf\u6e90\u7684\u8fde\u63a5\u901f\u5ea6\uff0c\u5e76**\u81ea\u52a8\u9009\u62e9\u6700\u5feb\u7684\u955c\u50cf\u6e90**\u3002\n\n## \u5feb\u901f\u4f7f\u7528\n\n\u8fd0\u884c\u4ee5\u4e0b\u547d\u4ee4\uff0c\u5feb\u901f\u5207\u6362\u4e3a\u6700\u5feb\u7684\u955c\u50cf\u6e90\uff1a\n\n```bash\npip install cnpip\ncnpip set\n```\n\n## \u529f\u80fd\n\n- **\u5217\u51fa\u5e76\u6d4b\u8bd5\u955c\u50cf\u6e90\u901f\u5ea6**\uff0c\u6309\u8fde\u63a5\u901f\u5ea6\u6392\u5e8f\n- **\u5feb\u901f\u5207\u6362 pip \u955c\u50cf\u6e90**\uff0c\u652f\u6301*\u624b\u52a8\u9009\u62e9*\u6216*\u81ea\u52a8\u9009\u62e9*\u6700\u5feb\u955c\u50cf\n\n## \u652f\u6301\u7684\u955c\u50cf\u6e90\n\n- [\u6e05\u534e\u5927\u5b66 TUNA](https://pypi.tuna.tsinghua.edu.cn/simple)\n- [\u4e2d\u56fd\u79d1\u5b66\u6280\u672f\u5927\u5b66 USTC](https://pypi.mirrors.ustc.edu.cn/simple)\n- [\u963f\u91cc\u4e91 Aliyun](https://mirrors.aliyun.com/pypi/simple)\n- [\u817e\u8baf Tencent](https://mirrors.cloud.tencent.com/pypi/simple)\n- [\u534e\u4e3a Huawei](https://repo.huaweicloud.com/repository/pypi/simple)\n- [\u9ed8\u8ba4\u6e90 PyPi](https://pypi.org/simple)\n\n## \u4f7f\u7528\u65b9\u6cd5\n\n### 1. \u5217\u51fa\u6240\u6709\u53ef\u7528\u7684\u955c\u50cf\u6e90\n\n```bash\ncnpip list\n```\n\n\u793a\u4f8b\u8f93\u51fa\uff1a\n\n```\n\u955c\u50cf\u540d\u79f0       \u8017\u65f6(ms)     \u5730\u5740\n--------------------------------------------------\nustc         135.71       https://pypi.mirrors.ustc.edu.cn/simple\naliyun       300.77       https://mirrors.aliyun.com/pypi/simple\ntuna         499.51       https://pypi.tuna.tsinghua.edu.cn/simple\ndefault      1252.75      https://pypi.org/simple\ntencent      1253.07      https://mirrors.cloud.tencent.com/pypi/simple\n```\n\n### 2. \u81ea\u52a8\u9009\u62e9\u6700\u5feb\u7684\u955c\u50cf\u6e90\n\n```bash\ncnpip set\n```\n\n\u793a\u4f8b\u8f93\u51fa\uff1a\n\n```\n\u672a\u6307\u5b9a\u955c\u50cf\u6e90\uff0c\u81ea\u52a8\u9009\u62e9\u6700\u5feb\u7684\u955c\u50cf\u6e90: ustc\n\u6210\u529f\u8bbe\u7f6e pip \u955c\u50cf\u6e90\u4e3a 'https://pypi.mirrors.ustc.edu.cn/simple'\n```\n\n### 3. \u9009\u62e9\u6307\u5b9a\u7684\u955c\u50cf\u6e90\n\n```bash\ncnpip set <\u955c\u50cf\u540d\u79f0>\n```\n\n\u793a\u4f8b\uff1a\n\n```bash\ncnpip set tuna\n```\n\n\u8f93\u51fa\uff1a\n\n```\n\u6210\u529f\u8bbe\u7f6e pip \u955c\u50cf\u6e90\u4e3a 'https://pypi.tuna.tsinghua.edu.cn/simple'\n```\n\n### 4. \u53d6\u6d88\u81ea\u5b9a\u4e49\u955c\u50cf\u6e90\u8bbe\u7f6e\n\n```bash\ncnpip unset\n```\n\n\u8f93\u51fa\uff1a\n\n```\n\u6210\u529f\u53d6\u6d88 pip \u955c\u50cf\u6e90\u8bbe\u7f6e\uff0c\u5df2\u6062\u590d\u4e3a\u9ed8\u8ba4\u6e90\u3002\n```\n\n## \u914d\u7f6e\u6587\u4ef6\n\n`cnpip` \u4f1a\u4fee\u6539\u6216\u521b\u5efa `pip` \u7684\u914d\u7f6e\u6587\u4ef6\u6765\u8bbe\u7f6e\u955c\u50cf\u6e90\uff1a\n\n- **Linux/macOS**: `~/.pip/pip.conf`\n- **Windows**: `%APPDATA%\\pip\\pip.ini`\n\n\u5728\u8bbe\u7f6e\u955c\u50cf\u6e90\u65f6\uff0c`cnpip` \u53ea\u4f1a\u4fee\u6539\u6216\u6dfb\u52a0 `index-url` \u914d\u7f6e\uff0c\u4e0d\u4f1a\u8986\u76d6\u5176\u4ed6\u914d\u7f6e\u9879\u3002\n\n## \u5e38\u89c1\u95ee\u9898\n\n### 1. \u4e3a\u4ec0\u4e48\u6211\u65e0\u6cd5\u8fde\u63a5\u5230\u67d0\u4e9b\u955c\u50cf\u6e90\uff1f\n\n\u67d0\u4e9b\u955c\u50cf\u6e90\uff08\u5982\u8c46\u74e3\uff09\u53ef\u80fd\u7531\u4e8e\u7f51\u7edc\u95ee\u9898\u6216\u955c\u50cf\u6e90\u672c\u8eab\u7684\u539f\u56e0\u65e0\u6cd5\u8fde\u63a5\u3002\u5728\u8fd9\u79cd\u60c5\u51b5\u4e0b\uff0c`cnpip` \u4f1a\u663e\u793a\u201c\u65e0\u6cd5\u8fde\u63a5\u201d\uff0c\u5e76\u5c06\u5176\u6392\u5728\u901f\u5ea6\u6d4b\u8bd5\u7ed3\u679c\u7684\u6700\u540e\u3002\n\n### 2. \u5982\u4f55\u6062\u590d\u4e3a\u9ed8\u8ba4\u7684 `pip` \u955c\u50cf\u6e90\uff1f\n\n\u4f7f\u7528 `unset` \u547d\u4ee4\u6062\u590d\u4e3a\u9ed8\u8ba4\u7684 `pip` \u955c\u50cf\u6e90\uff1a\n\n```bash\ncnpip unset\n```\n\n### 3. `cnpip` \u4f1a\u8986\u76d6\u6211\u7684 `pip.conf` \u6587\u4ef6\u5417\uff1f\n\n\u4e0d\u4f1a\u3002`cnpip` \u53ea\u4f1a\u4fee\u6539\u6216\u6dfb\u52a0 `index-url` \u914d\u7f6e\u9879\uff0c\u5176\u4ed6\u914d\u7f6e\u9879\u4f1a\u88ab\u4fdd\u7559\u3002\n\n## \u8bb8\u53ef\u8bc1\n\n\u672c\u9879\u76ee\u4f7f\u7528 [MIT \u8bb8\u53ef\u8bc1](LICENSE)\u3002\n\n---\n\n# cnpip (English)\n\n`cnpip` is a command-line tool designed specifically for users in **mainland China** to help quickly switch `pip`\nmirrors and improve Python package download speeds.       \nIt tests the connection speed of various mirrors and **automatically selects the fastest one**.\n\n> **Attention: This Python package is only available in Chinese mainland.**\n\n## Quick Start\n\nRun the following commands to quickly switch to the fastest mirror:\n\n```bash\npip install cnpip\ncnpip set\n```\n\n## Features\n\n- **List and test mirror speeds**, sorted by connection time\n- **Quickly switch pip mirrors**, supporting *manual selection* or *automatic selection* of the fastest mirror\n- Designed specifically for users in mainland China\n",
    "bugtrack_url": null,
    "license": null,
    "summary": "\u5e2e\u52a9\u4e2d\u56fd\u7528\u6237\u5feb\u901f\u5207\u6362 pip \u955c\u50cf\u6e90\uff0c\u63d0\u5347\u4e0b\u8f7d\u901f\u5ea6\u7684\u547d\u4ee4\u884c\u5de5\u5177.",
    "version": "1.2.0",
    "project_urls": {
        "Homepage": "https://github.com/caoergou/cnpip",
        "Issues": "https://github.com/caoergou/cnpip/issues"
    },
    "split_keywords": [
        "pip",
        " mirror",
        " chinese",
        " speed",
        " cli"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "22406b8182883d500d7f17f8c01a7b607122bde19de990c62dad8cac26ed0df7",
                "md5": "37c1a6efd4a305e60b7e9a88448e7c6f",
                "sha256": "7031a6243baea7e553658cf6173fc7a1cce6b25583e895f8ee7bd1de44207e25"
            },
            "downloads": -1,
            "filename": "cnpip-1.2.0-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "37c1a6efd4a305e60b7e9a88448e7c6f",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.7",
            "size": 7056,
            "upload_time": "2024-12-17T09:50:27",
            "upload_time_iso_8601": "2024-12-17T09:50:27.489528Z",
            "url": "https://files.pythonhosted.org/packages/22/40/6b8182883d500d7f17f8c01a7b607122bde19de990c62dad8cac26ed0df7/cnpip-1.2.0-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "2f538073c621b1855e51ea7494bd38adcf4ec3d8b4b2925ca5891c773bdcd982",
                "md5": "f4b476ccb2d701496dd0ecdd9ba90254",
                "sha256": "abbb37f21e2f12370ac624a0a0becdcee376736aef0f7efbb3cfb4acede84462"
            },
            "downloads": -1,
            "filename": "cnpip-1.2.0.tar.gz",
            "has_sig": false,
            "md5_digest": "f4b476ccb2d701496dd0ecdd9ba90254",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.7",
            "size": 6692,
            "upload_time": "2024-12-17T09:50:29",
            "upload_time_iso_8601": "2024-12-17T09:50:29.607413Z",
            "url": "https://files.pythonhosted.org/packages/2f/53/8073c621b1855e51ea7494bd38adcf4ec3d8b4b2925ca5891c773bdcd982/cnpip-1.2.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-12-17 09:50:29",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "caoergou",
    "github_project": "cnpip",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "lcname": "cnpip"
}
        
Elapsed time: 0.40350s