常用命令-python篇

1. pip 加速命令

pip install --index-url https://pypi.douban.com/simple  
pip install -i https://pypi.tuna.tsinghua.edu.cn/simple 

2. conda加速命令

  # 换用清华conda镜像 
 conda config --prepend channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/ 
  # 也换用科大conda镜像 
 conda config --prepend channels http://mirrors.ustc.edu.cn/anaconda/pkgs/free/
 conda config --set show_channel_urls yes 
 cat ~/.condarc #查看文件内容有无国内源信息,若有,则成功

3 添加python 路径

export PYTHONPATH=/home/ye/setup/caffe-master/python:$PYTHONPATH

4 python 主函数头

if __name__ == '__main__':
    main()

5. pip换源

##修改 ~/.pip/pip.conf (没有就创建一个), 
gedit  ~/.pip/pip.conf
##内容如下:
[global]
index-url = https://pypi.tuna.tsinghua.edu.cn/simple

6. pytorch设置卡号

import os
os.environ["CUDA_VISIBLE_DEVICES"] = "2"
如果有一天我们淹没在茫茫人海中庸碌一生,那一定是我们没有努力活得丰盛
原文地址:https://www.cnblogs.com/yeran/p/10448809.html