国内使用 Pip 和 GitHub 的优化方式

国内使用 Pip 和 GitHub 的优化方式

国内访问 PyPI 和 GitHub 速度较慢,以下优化方式可显著提升速度。

Pip 换源

使用国内镜像站加速 pip 安装:

# 临时使用
pip install -i https://pypi.tuna.tsinghua.edu.cn/simple package_name
# 永久配置
pip config set global.index-url https://pypi.tuna.tsinghua.edu.cn/simple

可用镜像源

  • 清华:https://pypi.tuna.tsinghua.edu.cn/simple
  • 阿里云:https://mirrors.aliyun.com/pypi/simple
  • 中科大:https://pypi.mirrors.ustc.edu.cn/simple
  • 华为云:https://repo.huaweicloud.com/repository/pypi/simple

GitHub 加速

方法一:使用镜像站

https://ghproxy.com/https://github.com/user/repo

方法二:修改 hosts
获取最新的 GitHub IP 解析,写入 /etc/hosts。
方法三:代理
通过 HTTP/HTTPS 代理访问 GitHub:

git config --global http.proxy http://127.0.0.1:7890
git config --global https.proxy http://127.0.0.1:7890

推荐

pip 换国内源是最简单有效的方式,GitHub 文件下载推荐用镜像站。

THE END
喜欢就支持一下吧
点赞0 分享 收藏
评论 抢沙发
欢迎您留下宝贵的见解!(至少 2 字)
提交
昵称

昵称

昵称 表情 快捷回复

    暂无评论内容