阿里云连接jupyter notebook的步骤

来源:互联网 发布:网络搞笑日语中文谐音 编辑:程序博客网 时间:2024/06/03 17:56

在这之前,用阿里云创建了实例,安装了Xshell5连接,并进行如下操作:

1. 安装anaconda

  • mkdir anaconda
  • cd anaconda
  • wget https://repo.continuum.io/archive/Anaconda3-4.4.0-Linux-x86_64.sh
  • bash Anaconda3-4.4.0-Linux-x86_64.sh

    这里注意的是:添加环境变量
    vim /etc/profile
    在文件末尾添加一行:export PATH=/home/grant/anaconda2/bin:$PATH
    其中,将“/home/grant/anaconda2/bin”换为实际的路径。保存。重启。打开终端,输入python,表示成功。

2. 配置环境,通过远程方式访问jupyter notebook

  • 1、生成配置文件
    jupyter notebook --generate-config
    如果出现提示-allow-root,请在之前的命令后面加 –allow-root
    jupyter notebook –generate-config –allow-root

  • 2、打开ipython,创建一个登录jupyter的密码

       [root@localhost ~]# ipython   In [1]: from notebook.auth import passwd   In [2]: passwd()   Enter password:    Verify password:    Out[2]: 'sha1:5311cd8b9da9:70dd3321fccb5b5d77e66080a5d3d943ab9752b4'   In [3]:exit

    其中记录下Out[2]里的:sha1:5311cd8b9da9:70dd3321fccb5b5d77e66080a5d3d943ab9752b4

  • 3、修改jupyper配置文件
    vi /root/.jupyter/jupyter_notebook_config.py 或者
    vi ~/.jupyter/jupyter_notebook_config.py
    在文件中添加以下的参数:

       c.NotebookApp.ip='*'   c.NotebookApp.password = u'sha1:5311cd8b9da9:70dd3321fccb5b5d77e66080a5d3d943ab9752b4'   c.NotebookApp.open_browser = False   c.NotebookApp.port =8888    #随便指定一个端口,使用默认8888也可以
  • 4、访问jupyter notebook
    jupyter notebook --ip=0.0.0.0 --no-browser --allow-root

  • 5、打开浏览器,输入http://192.168.1.100:8888
    192.168.1.100为主机公网名,如果发现无法访问,一般是系统防火墙没有关闭,使用以下命令进行关闭
    关闭ubuntu的防火墙:ufw disable

  • 6、再次访问,输入jupyter的登录密码,就可以正常访问了!

原创粉丝点击