0
点赞
收藏
分享

微信扫一扫

qt QNetworkProxy详解

梅梅的时光 2024-11-06 阅读 22

在国内,有许多常用的Python库镜像源可以帮助加速库的下载。以下是几个知名的镜像源:

1. 清华大学TUNA协会

  • 网址: https://pypi.tuna.tsinghua.edu.cn/simple
  • 命令示例:
    pip install numpy --index-url https://pypi.tuna.tsinghua.edu.cn/simple
    

2. 阿里云

  • 网址: http://mirrors.aliyun.com/pypi/simple/
  • 命令示例:
    pip install numpy --index-url http://mirrors.aliyun.com/pypi/simple/
    

3. 腾讯云

  • 网址: http://mirrors.cloud.tencent.com/pypi/simple/
  • 命令示例:
    pip install numpy --index-url http://mirrors.cloud.tencent.com/pypi/simple/
    

4. 华中科技大学

  • 网址: http://pypi.hustunique.com/
  • 命令示例:
    pip install numpy --index-url http://pypi.hustunique.com/
    

5. 中国科学技术大学

  • 网址: http://pypi.mirrors.ustc.edu.cn/simple/
  • 命令示例:
    pip install numpy --index-url http://pypi.mirrors.ustc.edu.cn/simple/
    

6. 豆瓣(Douban)

  • 网址: http://pypi.douban.com/simple/
  • 命令示例:
    pip install numpy --index-url http://pypi.douban.com/simple/
    

7. 镜像源配置

为了方便长期使用,你可以将pip的默认源设置为国内镜像源。可以通过编辑或创建~/.pip/pip.conf文件(Windows用户为%USERPROFILE%\pip\pip.ini)来配置。

示例配置文件:
[global]
index-url = https://pypi.tuna.tsinghua.edu.cn/simple

[install]
trusted-host = pypi.tuna.tsinghua.edu.cn

使用方法

假设你想使用清华大学TUNA协会的镜像源,可以按照以下步骤操作:

  1. 创建配置文件

    • 在Linux/Mac下,可以使用以下命令创建或编辑pip.conf文件:
      mkdir -p ~/.pip && tee ~/.pip/pip.conf > /dev/null <<EOF
      [global]
      index-url = https://pypi.tuna.tsinghua.edu.cn/simple
      
      [install]
      trusted-host = pypi.tuna.tsinghua.edu.cn
      EOF
      
    • 在Windows下,可以创建或编辑pip.ini文件:
      mkdir %USERPROFILE%\pip
      echo [global] > %USERPROFILE%\pip\pip.ini
      echo index-url = https://pypi.tuna.tsinghua.edu.cn/simple >> %USERPROFILE%\pip\pip.ini
      echo [install] >> %USERPROFILE%\pip\pip.ini
      echo trusted-host = pypi.tuna.tsinghua.edu.cn >> %USERPROFILE%\pip\pip.ini
      
  2. 验证配置

    • 使用pip list检查是否正确配置。
    • 使用pip install numpy测试安装一个库,看看是否从镜像源下载。

通过这些镜像源,你可以显著提升库的下载速度,从而提高开发效率。希望这些信息对你有所帮助!

举报

相关推荐

0 条评论