解决ubuntu的pip和apt-get太慢的问题
ubuntu国外龟速的源实在难受,还是自己动手更改一下各种pip 源和apt-get 的源吧,换了之后速度令人舒适!
-
更换pip源成清华源
-
临时使用:
可以在使用pip的时候加参数-i https://pypi.tuna.tsinghua.edu.cn/simple例如
pip install opencv-python -i https://pypi.tuna.tsinghua.edu.cn/simple
这样就从清华这边的镜像去安装opencv-python
-
永久修改
-
linux下,修改 ~/.pip/pip.conf (没有就创建一个), 修改 index-url至清华源,内容如下:
[global] index-url = https://pypi.tuna.tsinghua.edu.cn/simple
-
windows下,找到 C:Usersxxx(自己名字)AppDataRoamingpip,新建文件pip.ini,内容如下
[global] index-url = https://pypi.tuna.tsinghua.edu.cn/simple
-
-
-
更换apt-get成清华源
-
原文件备份(万一更换的源不行的时候,复制回来)
sudo cp /etc/apt/sources.list /etc/apt/sources.list.bak
-
编辑源列表文件
sudo vim /etc/apt/sources.list
-
将原来的列表删除,添加清华镜像源(https://mirrors.tuna.tsinghua.edu.cn/help/ubuntu/)
# 默认注释了源码镜像以提高 apt update 速度,如有需要可自行取消注释 deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ xenial main restricted universe multiverse # deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ xenial main restricted universe multiverse deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ xenial-updates main restricted universe multiverse # deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ xenial-updates main restricted universe multiverse deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ xenial-backports main restricted universe multiverse # deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ xenial-backports main restricted universe multiverse deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ xenial-security main restricted universe multiverse # deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ xenial-security main restricted universe multiverse # 预发布软件源,不建议启用 # deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ xenial-proposed main restricted universe multiverse # deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ xenial-proposed main restricted universe multiverse
-
sudo apt-get update 让更改生效
-
-
更换conda install源成清华源
-
编辑源列表文件
gedit ~/.condarc
-
删除文件内容,替换默认源成清华源
channels: - https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/ - defaults show_channel_urls: yes
-