Python开发常用命令

2019-11-01  本文已影响0人  乔咏田

conda

jupyter notebook --allow-root//启动,allow-root为root用户访问时需要添加的命令
pip install notebook -i https://pypi.douban.com/simple/ //安装
pip uninstall notebook  //卸载
jupyter notebook --generate-config //生成配置
pip install pyrsistent==0.15.0  //windows安装
c.NotebookApp.ip = '*'  # ip配置,防止Cannot assign requested address
c.NotebookApp.port = 8765  # port配置
c.NotebookApp.notebook_dir = '/root/notebook'  # 默认启动路径
c.NotebookApp.open_browser = False  # 是否打开浏览器
pip install -U jieba -i https://pypi.douban.com/simple/  # 安装或更新
conda upgrade --all  # 更新所有包
python setup.py install  # 使用源码安装
source activate python36 或  conda activate python36 # 进入环境,Linux需加source
source deactivate 或  conda deactivate # 退出环境,Linux需加source
conda env list  # 查看所有环境
conda create --name python36 python=3.6  # 创建环境,并指明python版本
conda env remove -n python36  # 删除环境
conda create -n cetc --clone /data/conda_env  # 导入环境
/miniconda3/envs/python36/lib/python3.6/site-packages # 包位置
mkdir software  # 具体路径根据自己实际情况进行选择,请在自己目录下面进行相关操作。
cd software
wget https://repo.continuum.io/miniconda/Miniconda3-latest-Linux-x86_64.sh
安装 bzip2  # 例如 apt-get install bzip2
sh Miniconda3-latest-Linux-x86_64.sh  # 安装conda
source ~/.bashrc  # 安装完毕后,使环境变量生效
conda env list  # 执行此命令检查是否安装成功
mkdir ~/.pip
cd ~/.pip/
vim pip.conf
# 以下为设置内容
[global]
index-url=http://mirrors.aliyun.com/pypi/simple/
[install]
trusted-host=http://mirrors.aliyun.com/pypi/simple/
清华大学:https://pypi.tuna.tsinghua.edu.cn/simple
阿里云:http://mirrors.aliyun.com/pypi/simple/
豆瓣:http://pypi.douban.com/simple/

模型训练

nvidia-smi  # 查看显卡占用
pip install torch torchvision  # 带有cuda的参照官网https://pytorch.org/

进程守护

tmux new -s python36 会话名    //新起一个会话
tmux ls     //查看现有的会话
tmux a  //进入最近的会话
tmux a -t  会话名  //进入指定会话
tmux kill-session -t 会话名 //干掉指定会话
tmux detach //离开会话

Ubuntu

apt install tmux # 安装软件
apt update  # apt更新
上一篇下一篇

猜你喜欢

热点阅读