「Python」conda与pip升级所有的包

conda:

conda update --a

pip:

pip freeze --local | grep -v '^-e' | cut -d = -f 1  | xargs -n1 sudo pip install -U # 有风险
pip freeze --user --local  | grep -v '^-e' | cut -d = -f 1  | xargs -n1 pip install --user -U # 升级用户的包

pip更换源:

mkdir -p ~/.config/pip
vim ~/.config/pip/pip.conf
[global]
index-url = https://pypi.tuna.tsinghua.edu.cn/simple