常用镜像源 | Linux, anaconda, huggingface, pip 等
最近在一台受限的Ubuntu上配置和使用开源项目。由于该服务器暂时无法访问墙外网站,故找了很多镜像网站作为替代
1. pip(pypi) 清华镜像源
https://pypi.tuna.tsinghua.edu.cn/simple
使用方法:
终端命令
pip install 包名 -i https://pypi.tuna.tsinghua.edu.cn/simple
2. Anaconda 下载清华镜像源
https://mirrors.tuna.tsinghua.edu.cn/anaconda/archive/
使用方法(Linux)
wget https://mirrors.tuna.tsinghua.edu.cn/anaconda/archive/Anaconda3-2024.06-1-Linux-x86_64.sh
如果wget not found
则先安装
sudo apt install wget
如果403 Forbidden
则加上User-Agent
wget -U 'Mozilla' https://mirrors.tuna.tsinghua.edu.cn/anaconda/archive/Anaconda3-2024.06-1-Linux-x86_64.sh
(参考[[https://www.cnblogs.com/haoliyou/p/17666790.html|此篇]])
3. GitHub 镜像源
https://gitclone.com
https://kkgithub.com
使用方法:在镜像网站找到对应代码仓库,复制地址
git clone 镜像地址
4. 更新submodule
有的项目会包含子模块需要更新,找到.gitmodule
文件,将其中url = https://github.com/XXX/XXX.git
改为
url = https://kkgithub.com/XXX/XXX.git
或者在本地更新完后上传
5. HuggingFace 镜像
原址常见错误: connectionerror: HTTPSConnectionPool(host='huggingface.co', port=443): Read timed out.
镜像地址 https://hf-mirror.com
换源方法(对于一些国外的开源项目无需手动更改代码):
pip install -U huggingface_hub
export HF_ENDPOINT=https://hf-mirror.com
补充:使用 hf_transfer
加速下载
pip install hf_transfer
export HF_HUB_ENABLE_HF_TRANSFER=1 # 启用transfer
注意:使用国内镜像源+Transfer时可能会被限流而停止
(更多有关HuggingFace模型下载内容,可以参考[[https://zhuanlan.zhihu.com/p/663712983|这篇]])
5. conda install 增加国内镜像源
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main/
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud//pytorch/
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge/
conda config --set show_channel_urls yes
参考自https://www.cnblogs.com/fireblackman/p/16422750.html
202409再更新:
由于服务器更换,转为使用CentOS 7,同样需要换源。
6. yum 换国内镜像源
在使用centOS内置的yum
安装screen
时报错:
Loaded plugins: fastestmirror, ovl
Determining fastest mirrors
Could not retrieve mirrorlist http://mirrorlist.centos.org/?release=7&arch=x86_64&repo=os&infra=container error was
14: curl#6 - "Could not resolve host: mirrorlist.centos.org; Unknown error"
One of the configured repositories failed (Unknown),
and yum doesn't have enough cached data to continue. At this point the only
safe thing yum can do is fail. There are a few ways to work "fix" this:
1. Contact the upstream for the repository and get them to fix the problem.
2. Reconfigure the baseurl/etc. for the repository, to point to a working
upstream. This is most often useful if you are using a newer
distribution release than is supported by the repository (and the
packages for the previous distribution release still work).
3. Run the command with the repository temporarily disabled
yum --disablerepo=<repoid> ...
4. Disable the repository permanently, so yum won't use it by default. Yum
will then just ignore the repository until you permanently enable it
again or use --enablerepo for temporary usage:
yum-config-manager --disable <repoid>
or
subscription-manager repos --disable=<repoid>
5. Configure the failing repository to be skipped, if it is unavailable.
Note that yum will try to contact the repo. when it runs most commands,
so will have to try and fail each time (and thus. yum will be be much
slower). If it is a very temporary problem though, this is often a nice
compromise:
故需要对yum换源
6.1 备份
mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.backup
6.2 下载镜像源
wget -O /etc/yum.repos.d/CentOS-Base.repo 地址
- 阿里:http://mirrors.aliyun.com/repo/
- 网易: http://mirrors.163.com/.help/
- 中科大:http://centos.ustc.edu.cn/
示例:
wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo
6.3 清除缓存并更新
yum clean all
yum makecache
6.4 检查
尝试更新或者安装以检查yum是否正常工作
yum update
或 不更新yum内核
yum --exclude=kernel* update
参考自:[https://blog.csdn.net/m0_49605975/article/details/120039048]
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· Manus重磅发布:全球首款通用AI代理技术深度解析与实战指南
· 被坑几百块钱后,我竟然真的恢复了删除的微信聊天记录!
· 没有Manus邀请码?试试免邀请码的MGX或者开源的OpenManus吧
· 园子的第一款AI主题卫衣上架——"HELLO! HOW CAN I ASSIST YOU TODAY
· 【自荐】一款简洁、开源的在线白板工具 Drawnix