Linux修改系統以及pip更新源


Linux修改系統以及pip更新源

時間:2015-08-01 來源:csdn  作者:henulwj

修改系統更新源

你是否跟我一樣在剛看時接觸Linux時被系統更新源問題搞得暈頭轉向,不同的Linux更新源配置也是不一樣的,另外由於默認安裝時的源大都是外國的更新源,速度相對國內會慢很多,接下來主要介紹在centos和ubuntu系統中更新系統源的方法,更新源以163的更新源為例。


centos更新系統源

首先備份/etc/yum.repos.d/CentOS-Base.repo

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

下載對應版本repo文件, 放入/etc/yum.repos.d/(再次提醒操作前請做好相應備份)
CentOS7
CentOS6
CentOS5
最后運行一下命令生成緩存

yum clean all
yum makecache

盡情享受飛一般的速度吧


ubuntu更新系統源

首先備份/etc/apt/sources.list

mv /etc/apt/sources.list /etc/apt/sources.list.bak

然后下載相應版本的sources.list, 覆蓋/etc/apt/sources.list即可(再次提醒操作前請做好相應備份)
lucid(10.04)
precise(12.04)
trusty(14.04)
utopic(14.10)
vivid(15.04)
wily(15.10)
覆蓋完成之后即可使用,如果不做備份也可以直接修改/etc/apt/sources.list文件,以Wily(15.10)為例, 編輯/etc/apt/sources.list文件, 在文件最前面添加以下條目(再次操作前請做好相應備份)

deb http://mirrors.163.com/ubuntu/ wily main restricted universe multiverse
deb http://mirrors.163.com/ubuntu/ wily-security main restricted universe multiverse
deb http://mirrors.163.com/ubuntu/ wily-updates main restricted universe multiverse
deb http://mirrors.163.com/ubuntu/ wily-proposed main restricted universe multiverse
deb http://mirrors.163.com/ubuntu/ wily-backports main restricted universe multiverse
deb-src http://mirrors.163.com/ubuntu/ wily main restricted universe multiverse
deb-src http://mirrors.163.com/ubuntu/ wily-security main restricted universe multiverse
deb-src http://mirrors.163.com/ubuntu/ wily-updates main restricted universe multiverse
deb-src http://mirrors.163.com/ubuntu/ wily-proposed main restricted universe multiverse
deb-src http://mirrors.163.com/ubuntu/ wily-backports main restricted universe multiverse

修改完成保存
最后需要執行

sudo apt-get update


修改pip更新源

pip安裝時默認訪問pypi的,但是pypi的速度對於國內來說有點慢,還在國內也有一些pip的鏡像源,造福廣大程序員
pipy國內鏡像目前有:
http://pypi.douban.com/ 豆瓣
http://pypi.hustunique.com/ 華中理工大學
http://pypi.sdutlinux.org/ 山東理工大學
http://pypi.mirrors.ustc.edu.cn/ 中國科學技術大學
安裝時我們可以手動指定安裝源如下:

pip -i http://pypi.douban.com/simple install Flask

如果感覺每次安裝都手動指定安裝源麻煩的話,也可以配置pip更新源


在主目錄下創建.pip文件夾

mkdir ~/.pip

然后在該目錄下創建pip.conf文件編寫如下內容:

[global]
trusted-host =  pypi.douban.com
index-url = http://pypi.douban.com/simple

這里以豆瓣的源為例,由於最新的pip安裝需要使用的https加密,所以在此需要添加trusted-host
對於window系統來說基本配置相同創建或修改配置文件在%HOMEPATH%\pip\pip.ini


參考鏈接:

http://topmanopensource.iteye.com/blog/2004853
http://mirrors.163.com/.help/ubuntu.html
http://mirrors.163.com/.help/centos.html


Ubuntu下apt-get與pip安裝命令的區別:http://www.linuxdiyf.com/linux/13091.html

為Linux配置apt-get的更新源:http://www.linuxdiyf.com/linux/12073.html

Ubuntu 15.10更新源已可用,更新到Ubuntu 15.10的方法:http://www.linuxdiyf.com/linux/11955.html

Ubuntu 15.04更新源:http://www.linuxdiyf.com/linux/11839.html

CentOS修改yum更新源:http://www.linuxdiyf.com/linux/12447.html


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM