装环境必备命令

我装了三天三夜的环境,然后一手抖把虚拟机删了,然后重复不知几次之后, 总结出来的经验是一定要先换源

pip

# 豆瓣
https://pypi.doubanio.com/simple/
# 阿里云    
https://mirrors.aliyun.com/pypi/simple/
# 清华大学
https://pypi.tuna.tsinghua.edu.cn/simple/
https://mirrors.tuna.tsinghua.edu.cn/pypi/web/simple/

升级 pip 到最新的版本后进行配置:

pip install pip -U
pip config set global.index-url https://mirrors.tuna.tsinghua.edu.cn/pypi/web/simple/

conda

1.conda源更换为清华
只需输入如下两行命令:

conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/
conda config --set show_channel_urls yes

2.conda源更换为中科大

只需输入如下两行命令:

conda config --add channels https://mirrors.ustc.edu.cn/anaconda/pkgs/free/

conda config --set show_channel_urls yes

记得删掉c:/usr/usrname里的.condarc原有的清华镜像

3.如果需要换回conda的默认源。查看了conda config的文档后,发现直接删除channels即可。命令如下:

conda config --remove-key channels

apt get

更换方法:

cp /etc/apt/sources.list /etc/apt/sources.list.bak
sed -i 's/:\/\/\(.*\)\//:\/\/<源域名>/g' /etc/apt/sources.list
apt-get update

其中,
清华源域名:mirrors.tuna.tsinghua.edu.cn
中科大源域名:mirrors.ustc.edu.cn

yum

1.首先备份当前配置文件

mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.backup

2.下载新的 CentOS-Base.repo 到 /etc/yum.repos.d
对于CentOS8

wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-8.repo
  1. 运行 yum makecache 生成缓存
yum makecache

参考链接:
https://www.jianshu.com/p/bb4bff1f4bbc
https://blog.csdn.net/Arylu/article/details/83659221
https://www.cnblogs.com/believepd/p/10499844.html
https://zhuanlan.zhihu.com/p/106719292

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值