设pip默认镜像源

一、linux 或mac下设置pip默认镜像源

1. 创建配置文件

```
mkdir -p ~/.pip
```

2. 修改镜像源(使用vi打开文件pip.config,将下面内容粘贴到文件中保存即可)

```
vi  ~/.pip/pip.conf
```
```
[global]
timeout = 6000
index-url = https://mirrors.aliyun.com/pypi/simple/
trusted-host = mirrors.aliyun.com
```

二、windows下设置pip默认镜像源

打开我的电脑,在地址栏中输入 %APPDATA% 按回车跳转到目标目录。在目录下创建一个pip文件,再其内部创建一个pip.ini 文件。输入以下信息。以阿里云为例

[global]
timeout = 6000
index-url = https://mirrors.aliyun.com/pypi/simple/
trusted-host = mirrors.aliyun.com

python脚本自动生成

    import os
    import pathlib
    from os.path import join, exists
    
    pip_path = join(pathlib.Path.home(), "AppData", "Roaming", "pip")
    pip_filename = join(pip_path, "pip.ini")
    pip_text = "\n".join([
        "[global]", "timeout = 6000",
        "index-url = https://mirrors.aliyun.com/pypi/simple/",
        "trusted-host = mirrors.aliyun.com"
    ])
    
    if not exists(pip_path):
        os.makedirs(pip_path)
        
    with open(pip_filename, mode='w', encoding='utf8') as fp:
        fp.write(pip_text)

三、 其他镜像源地址

  • 阿里云:https://mirrors.aliyun.com/pypi/simple/
  • 清华:https://pypi.tuna.tsinghua.edu.cn/simple
  • 中国科技大学 https://pypi.mirrors.ustc.edu.cn/simple/
  • 华中理工大学:http://pypi.hustunique.com/
  • 山东理工大学:http://pypi.sdutlinux.org/
  • 豆瓣:http://pypi.douban.com/simple/
GitHub 加速计划 / li / linux-dash
10
1
下载
A beautiful web dashboard for Linux
最近提交(Master分支:9 个月前 )
186a802e added ecosystem file for PM2 5 年前
5def40a3 Add host customization support for the NodeJS version 5 年前
Logo

旨在为数千万中国开发者提供一个无缝且高效的云端环境,以支持学习、使用和贡献开源项目。

更多推荐