Ubuntu 之更换与使用apt源和python源(仅对zju内网适用)

Ubuntu 之更换与使用apt源和python源.mdpython

一键更换脚本内容

#! /bin/bash
echo "设置浙大镜像源"
(cat << EOF
deb http://mirrors.zju.edu.cn/ubuntu xenial main universe restricted multiverse
deb http://mirrors.zju.edu.cn/ubuntu xenial-security main universe restricted multiverse
deb http://mirrors.zju.edu.cn/ubuntu xenial-updates main universe restricted multiverse
deb http://mirrors.zju.edu.cn/ubuntu xenial-backports main universe restricted multiverse
deb-src http://mirrors.zju.edu.cn/ubuntu xenial main universe restricted multiverse
deb-src http://mirrors.zju.edu.cn/ubuntu xenial-security main universe restricted multiverse
deb-src http://mirrors.zju.edu.cn/ubuntu xenial-updates main universe restricted multiverse
deb-src http://mirrors.zju.edu.cn/ubuntu xenial-backports main universe restricted multiverse
EOF
) | sudo tee /etc/apt/sources.list
echo "写入浙大Ubuntu16.04 amd64 apt镜像源完成"
sudo apt update


echo "如今开始修改Python的Zju pipy源:"
cd ~
mkdir .pip
cd .pip
(cat << EOF
index-url=http://mirrors.zju.edu.cn/pypi/web/simple
trusted-host=mirrors.zju.edu.cn
disable-pip-version-check =true
EOF
) | sudo tee ~/.pip/pip.conf
echo "更换成Zju Pipy源完成"
echo "注意若是须要安装Python3的安装包,请使用如下命令:python3 -m pip install numpy"
echo "注意若是须要安装Python2的安装包,请使用如下命令:python2 -m pip install numpy"
echo "不建议你们直接用pip install的方式安装python包,这样你会不清楚装的是python2的包仍是python3的包"

修改Ubuntu apt源

打开/etc/apt/sources.list文件,删除里面全部内容,添加如下内容进去,保存便可。web

deb http://mirrors.zju.edu.cn/ubuntu xenial main universe restricted multiverse
deb http://mirrors.zju.edu.cn/ubuntu xenial-security main universe restricted multiverse
deb http://mirrors.zju.edu.cn/ubuntu xenial-updates main universe restricted multiverse
deb http://mirrors.zju.edu.cn/ubuntu xenial-backports main universe restricted multiverse
deb-src http://mirrors.zju.edu.cn/ubuntu xenial main universe restricted multiverse
deb-src http://mirrors.zju.edu.cn/ubuntu xenial-security main universe restricted multiverse
deb-src http://mirrors.zju.edu.cn/ubuntu xenial-updates main universe restricted multiverse
deb-src http://mirrors.zju.edu.cn/ubuntu xenial-backports main universe restricted multiverse

注意:
这种方式修改的apt源,对同系统全部用户都有效ubuntu

修改Ubunt 的Python 源

在用户本身主目录下面,先新建文件夹.pip,而后在.pip文件夹下建立名为pip.conf的文件。其文件内容以下:最后保存便可。bash

[global]
index-url=http://mirrors.zju.edu.cn/pypi/web/simple
trusted-host=mirrors.zju.edu.cn
disable-pip-version-check =true

注意:
这种形式修改的pipy源只对当前用户生效。
不推荐用户直接使用pip install的方式安装包(容易不清楚安装的是python3仍是python2的包)。
推荐使用如下命令安装python包:url

注意若是须要安装Python3的安装包,请使用如下命令:python3 -m pip install numpy***
注意若是须要安装Python2的安装包,请使用如下命令:python2 -m pip install numpy***
相关文章
相关标签/搜索