Linux下jupyter环境搭建和远程连接

  • 通过 wget 下载 anaconda 安装包

    wget https://repo.anaconda.com/archive/Anaconda3-5.3.1-Linux-x86_64.sh

    利用 bash 命令安装到 anaconda 文件夹下

    bash Anaconda3-5.3.1-Linux-x86_64.sh -p anaconda/ -u

     

    conda测试环境

    输入命令conda --version,有版本信息则说明安装成功,否则可能没有将conda加入环境变量中,需执行:

    export PATH=~/anaconda3/bin:$PATH
    source ~/.bashrc

     

    增加conda的镜像(这边以中科大镜像为例,也可增加清华镜像)
    conda config --add channels Index of /anaconda/pkgs/free/ | 北京外国语大学开源软件镜像站 | BFSU Open Source Mirror

    去掉conda的镜像
    conda config --remove channels Index of /anaconda/pkgs/free/ | 北京外国语大学开源软件镜像站 | BFSU Open Source Mirror

     

    conda创建虚拟环境

    conda create -n env_name python=3.5

     

    conda激活虚拟环境

    conda activate env_name

     

    conda修复本地环境

    conda upgrade --all

     

    jupyter环境

    jupyter安装nbextensions

    pip install jupyter_nbextensions_configurator
    jupyter nbextensions_configurator enable --user

  •  

  • 设置jupyter notebook密码:
    • jupyter notebook password
  • 在ipython中获取hash密码:
    • from notebook.auth import passwd
    • passwd()
    • 保存新生成的密码
  • 设置jupyter设置文件
    • 生成配置文件
      • jupyter notebook --generate-config
    • 打开配置文件
      • vim /root/.jupyter/jupyter_notebook_config.py
    • 设置行号
      • :set nu
    • 设置文件
    • c.NotebookApp.notebook_dir = '/root/notebook' # notebook默认目录
    • c.NotebookApp.ip = 'xx.xx.xxx.xx' # 设置登录ip地址,即本机地址
    • c.NotebookApp.password = u'sha1:bcd259ccf...<your hashed password here>'
    • c.NotebookApp.open_browser = False
  •  
  • 从控制台直接启动jupyter
    • jupyter notebook password
    • jupyter notebook --allow-root
  •  
  • 指定启动端口
    • jupyter notebook --port <port_number>
  •  
  • 后台运行jupyter
    • nohup jupyter notebook --allow-root > jupyter.log 2>&1 &
  •  
  • jupyter登录:
    • jupyter登录地址:http://xx.xx.xxx.xx:8888/tree?
    • 密码:u'sha1:bcd259ccf...<your hashed password here>'
  •  
  • jupyter安装nbextension
    • jupyter contrib nbextension install --user --skip-running-check
    • 或者执行以下命令:
    • pip install jupyter_contrib_nbextensions -i https://mirrors.tuna.tsinghua.edu.cn/pypi/web/simple/
    • jupyter contrib nbextension install --user
  •  
  • 查询jupyter运行进程
    • ps -ef | grep jupyter
  •  
  • 关闭运行中的进程
    • kill -9 <PID number>
  •  
  • 对于好不容易配置好的环境,将其中的包,版本号等导出作为记录是很重要的一件事,这便于我们对环境的安装进行再次的复现。
  • 导出已有环境:
    • conda env export > environment.yaml
  • 环境会被保存在 environment.yaml文件中。
  • 当我们想再次创建该环境,或根据别人提供的.yaml文件复现环境时,可以:
    • conda env create -f environment.yaml

 

  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值