Brew, Pip, Yum change domestic source

Turning over the crowds

Brew and pip are two kinds of package management software commonly used on mac, but unfortunately they are all foreign products, so the default source is also foreign, the speed is a lot of wall cards, so it needs to be replaced into a domestic source. Yum is the package management tool of the centos operating system. The default source is also foreign, and the speed is slow.

brew

Brew is a package management tool on mac, similar to apt-get on ubuntu, yum on centos.

Installing brew

1
ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"

Using brew

1
brew install

Replacement source

The default source speed of brew is too slow, sometimes it will be replaced by a wall…, which can be replaced by the source of China University of Science and Technology.

Replace brew.git
1
2
cd "$(brew --repo)"
git remote set-url origin https://mirrors.ustc.edu.cn/brew.git
Replace homebrew-core.git
1
2
cd "$(brew --repo)/Library/Taps/homebrew/homebrew-core"
git remote set-url origin https://mirrors.ustc.edu.cn/homebrew-core.git
Replace Homebrew Bottles Source

For bash users:

1
2
echo 'export HOMEBREW_BOTTLE_DOMAIN=https://mirrors.ustc.edu.cn/homebrew-bottles' >> ~/.bash_profile
source ~/.bash_profile

For zsh users:

1
2
echo 'export HOMEBREW_BOTTLE_DOMAIN=https://mirrors.ustc.edu.cn/homebrew-bottles' >> ~/.zshrc
source ~/.zshrc

Note: It is recommended to replace the above three sources, and then update the brew update.

pip

Pip is python’s package management tool, similar to node.js’ npm management tool.

Install

1
sudo apt-get install python-pip

or:

1
2
3
wget "https://pypi.python.org/packages/source/p/pip/pip-1.5.4.tar.gz#md5=834b2904f92d46aaa333267fb1c922bb"
After unzipping, go to the setuptools file directory and run sudo python setup.py install.
Then go to the pip file directory and run sudo python setup.py install.

Usage

  • pip list # lists all installed libraries
  • pip list –outdated # List all expired libraries
  • pip install –upgrade library name # update library
  • pip install –upgrade pip # update pip itself
  • pip freeze # See which packages are installed
  • pip install -t /usr/local/lib/python2.7/site-packages/ xlrd # install the library for the specified version of python
  • pip install jieba -i https://pypi.douban.com/simple # Single use domestic source installation

Replace pip source

The speed of foreign sources is too slow to download in the country, so you need to change the mirror source, you can change it to Alibaba Cloud or Douban.

Temporary use of domestic sources
1
Pip install jieba -i https://pypi.douban.com/simple # Single use domestic source installation
Modifying the configuration file

Edit the pip.cofig file, the file location (create one if it doesn’t exist):

  • mac:~/.pip/pip.conf
  • linux:~/.pip/pip.conf
  • windows:% HOMEPATH% \ pip \ pip.ini
1
2
3
4
5
[global]
index-url=http://mirrors.aliyun.com/pypi/simple/
[install]
trusted-host=mirrors.aliyun.com

Save and exit.

pip error handling

Error message:

1
OSError: [Errno 1] Operation not permitted:

solution:

1
2
pip install --upgrade pip
sudo pip install numpy --ignore-installed

yum

Backup

First back up the /etc/yum.repos.d/CentOS-Base.repo file:

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

Download domestic source files

Download the corresponding version of the repo file and put it in /etc/yum.repos.d/, such as Netease Source:

Note: You can also modify the source address in the CentOS-Base.repo file without downloading.

Cache

Run the following command to generate the cache:

1
2
Yum clean all
Yum makecache

本文标题:Brew, Pip, Yum change domestic source

文章作者:nmask

发布时间:2017年08月24日 - 14:08

最后更新:2019年08月16日 - 15:08

原始链接:https://thief.one/2017/08/24/1/en/

许可协议: 署名-非商业性使用-禁止演绎 4.0 国际 转载请保留原文链接及作者。

nmask wechat
欢迎您扫一扫上面的微信公众号,订阅我的博客!
坚持原创技术分享,您的支持将鼓励我继续创作!

热门文章推荐: