linux jupyter lab 如何永久切换镜像源

一、问题背景

笔者在更新Linux上使用的JupyterLab的扩展应用时,下载的速度非常慢,每次安装扩展程序之后ipython环境都要Rebuild一下,导致扩展程序经常需要加载。


搞的有些怀疑人生的我,就通过conda uninstall jupyterlab重新安转了一遍jupyterlab,结果发现重装之后还是得rebuild,非常抓狂啊!

二、问题溯源

2.1 国外镜像源的问题

经常卡死,下载慢。很可能是因为python默认镜像是国外的,导致水管细,流量小

三、问题解决

2.1 国外镜像源问题解决

方案1:临时增加镜像源

国外镜像源列表

清华大学 https://pypi.tuna.tsinghua.edu.cn/simple/
阿里云 https://mirrors.aliyun.com/pypi/simple/
豆瓣 http://pypi.douban.com/simple/
中国科学技术大学 http://pypi.mirrors.ustc.edu.cn/simple/

有很多临时方法强制在下载的时候使用国外镜像源,即使用下列命令:

pip install 某包 -i 镜像源
conda install 某包 -i 镜像源

难道我每次下载还得去打上镜像源地址吗,Creazy!!!

方案2:永久增加镜像源

step1:生成.condarc文件
conda config --set show_channel_urls yes
上步成功操作后会在用户主目录~下多个.condarc空文件
step2:vim编辑 ~/.condarc 保存,退出
vim .condarc

channels:
  - defaults
show_channel_urls: true
channel_alias: https://mirrors.tuna.tsinghua.edu.cn/anaconda
default_channels:
  - https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main
  - https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free
  - https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/r
  - https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/pro
  - https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/msys2
custom_channels:
  conda-forge: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud
  msys2: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud
  bioconda: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud
  menpo: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud
  pytorch: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud
  simpleitk: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud

运行conda clean -i清除索引缓存,保证用的是镜像站提供的索引。
到此,一劳永逸的解决方案,赶紧找个模块测试一下吧。

全部评论

相关推荐

不愿透露姓名的神秘牛友
05-28 12:15
点赞 评论 收藏
分享
不愿透露姓名的神秘牛友
07-04 18:02
好不容易拿到了字节Offer,鼠鼠做后端的,但家里人觉得可能被裁员不稳定,让鼠鼠去投国企,现在好纠结到底该咋选
文档传偷助手:该投就投吧,不过建议别放弃offer 拿到手里的才是最好的
投递字节跳动等公司9个岗位
点赞 评论 收藏
分享
评论
点赞
1
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务