头像

Cyan

四川成都

深度强化学习炼丹师

国内镜像换源

国内镜像换源

2022-04-04 · 269次阅读 · 原创 · 随笔

1. Python pip

查看当前源

pip config list

临时换源

pip install xxx -i https://pypi.tuna.tsinghua.edu.cn/simple

永久换源

脚本配置方式

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

文件配置方式

WindowsC:\Users\用户名\pip 下,创建文件 pip.ini,在 pip.ini 中输入以下内容:

[global] index-url = https://pypi.tuna.tsinghua.edu.cn/simple [install] trusted-host = pypi.tuna.tsinghua.edu.cn

Linux、MacOS/home/用户名/.pip 下创建 pip.conf 文件,文件内容同 Windows

其它源地址

# 清华源 https://pypi.tuna.tsinghua.edu.cn/simple # 阿里源 https://mirrors.aliyun.com/pypi/simple/ # 腾讯源 http://mirrors.cloud.tencent.com/pypi/simple # 豆瓣源 http://pypi.douban.com/simple/ # 换回默认源 pip config unset global.index-url

2. Node npm

查看当前源

npm config get registry

临时换源

npm --registry https://registry.npm.taobao.org install XXX(module-name)

永久换源

脚本配置方式

npm config set registry https://registry.npm.taobao.org # 还原默认源:npm config set registry https://registry.npmjs.org/

文件配置方式

WindowsC:\Users\用户名下创建文件 .npmrcLinux、MacOS/home/用户名 下创建 .npmrc文件,其内容如下:

registry = http://registry.npm.taobao.org/

3. Ubuntu 镜像源

具体步骤

  1. 打开 /etc/apt/sources.list 文件,用 # 注释掉原来的源(:最好将原来的文件做好备份)
  2. 添加镜像源,按后文给出的国内镜像源进行粘贴
  3. 保存并退出文件
  4. 执行命令:apt-get update 进行源文件的更新

注意

不同的ubuntu版本有不一样的代号,如下面中的 focal 是Ubuntu 20.04的代号,需要按照自己的系统代号进行替换,使用 lsbrelease -a 查看自己的系统版本号,如:

Ubtuntu系统版本

可以看到代号为 focal ,则下面每条语句都更新为对应的代号即可。

国内源

  • 清华源
deb http://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal main restricted deb http://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal-updates main restricted deb http://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal universe deb http://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal-updates universe deb http://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal multiverse deb http://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal-updates multiverse deb http://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal-backports main restricted universe multiverse deb http://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal-security main restricted deb http://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal-security universe deb http://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal-security multiverse
  • 中科大源
deb https://mirrors.ustc.edu.cn/ubuntu/ focal main restricted universe multiverse deb-src https://mirrors.ustc.edu.cn/ubuntu/ focal main restricted universe multiverse deb https://mirrors.ustc.edu.cn/ubuntu/ focal-updates main restricted universe multiverse deb-src https://mirrors.ustc.edu.cn/ubuntu/ focal-updates main restricted universe multiverse deb https://mirrors.ustc.edu.cn/ubuntu/ focal-backports main restricted universe multiverse deb-src https://mirrors.ustc.edu.cn/ubuntu/ focal-backports main restricted universe multiverse deb https://mirrors.ustc.edu.cn/ubuntu/ focal-security main restricted universe multiverse deb-src https://mirrors.ustc.edu.cn/ubuntu/ focal-security main restricted universe multiverse deb https://mirrors.ustc.edu.cn/ubuntu/ focal-proposed main restricted universe multiverse deb-src https://mirrors.ustc.edu.cn/ubuntu/ focal-proposed main restricted universe multiverse
  • 阿里源
# 阿里镜像源 deb http://mirrors.aliyun.com/ubuntu/ focal main restricted universe multiverse deb http://mirrors.aliyun.com/ubuntu/ focal-security main restricted universe multiverse deb http://mirrors.aliyun.com/ubuntu/ focal-updates main restricted universe multiverse deb http://mirrors.aliyun.com/ubuntu/ focal-proposed main restricted universe multiverse deb http://mirrors.aliyun.com/ubuntu/ focal-backports main restricted universe multiverse deb-src http://mirrors.aliyun.com/ubuntu/ focal main restricted universe multiverse deb-src http://mirrors.aliyun.com/ubuntu/ focal-security main restricted universe multiverse deb-src http://mirrors.aliyun.com/ubuntu/ focal-updates main restricted universe multiverse deb-src http://mirrors.aliyun.com/ubuntu/ focal-proposed main restricted universe multiverse deb-src http://mirrors.aliyun.com/ubuntu/ focal-backports main restricted universe multiverse


标题: 国内镜像换源
链接: https://www.fightingok.cn/detail/222
更新: 2023-03-31 18:18:35
版权: 本文采用 CC BY-NC-SA 3.0 CN 协议进行许可