美文网首页程序员我用 Linux
四、Arch Linux Cheat Sheet (Jupyte

四、Arch Linux Cheat Sheet (Jupyte

作者: 华丽同行 | 来源:发表于2016-12-21 23:01 被阅读465次

    ArchLinuxVirtualBoxpythonjupyter notebook serverjupyter-C-Kernel


    上一篇·GIT配置


    一、安装

    安装Python
    pacman -Sy python
    
    安装Pip
    pacman -Sy python-pip
    
    安装jupyther
    pip install jupyter
    

    二、配置Jupyter notebook server

    注意:未测试外网云主机类,当前虚拟机设置的是桥接模式,相当于局域网内主机

    1. 生成Jupyter配置文件
    jupyter notebook --generate-config
    # 生成的配置文件位于 ~/.jupyter/jupyter_notebook_config.py 
    
    2. 生成自认证的SSL证书
    由于jupyter -notebook登陆必须使用https 方式,因此需要指定证书
    cd ~/.jupyter # 准备在这里生成
    openssl req -x509 -nodes -days 365 -newkey rsa:1024 -keyout notebook_key.key -out notebook_cert.pem
    # 命令执行当中需要输入用户信息,可全部按照默认。
    

    上述命令生成了两个文件notebook_key.keynotebook_cert.pem,留用。

    3.生成jupyter‘认可’的加密密码
    python -c "from notebook.auth import passwd; print(passwd())" 
    

    上述命令除了让你设置密码之外,还会输出将你的密码加密过的SHA1值,如:
    sha1:991ec9cd2f39:522598e19891bab1ecaa3a9072e71f45811af9f2
    记下它 [ 黑人问号??]。

    Tip : 因为我使用的是Xshell登陆的,可以直接将此值复制粘贴,如果单纯是在ArchLinux里面操作的话,可以将上述命令改为:

    python -c "from notebook.auth import passwd; print(passwd())" > afile
    

    这样设置完密码之后sha1值会输出到afile文件当中的,之后就可以通过Vim复制了。

    4. 修改Jupyter配置文件
    vim  ~/.jupyter/jupyter_notebook_config.py 
    

    修改或直接添加以下内容:

    c.NotebookApp.certfile = u'~/.jupyter/notebook_cert.pem'
    c.NotebookApp.keyfile = u'~/.jupyter/notebook_key.key'
    c.NotebookApp.password = u'sha1:991ec9cd2f39:522598e19891bab1ecaa3a9072e71f45811af9f2'
    c.NotebookApp.ip = '*'
    c.NotebookApp.port = 8888
    c.NotebookApp.open_browser = False
    

    三、登陆

    1. 确认IP地址
    ip addr  # 我的192.165.0.103
    
    2. 启动服务
    jupyter notebook
    
    3. 在宿主系统中打开浏览器,地址栏中输入:
    https://192.165.0.103:8888 # 必须是https开头。
    

    之后浏览器会提示证书风险,忽略,出现密码框,输入密码登陆,之后你可能觉得应该在启动服务之前换一个目录_

    四、增加C-Kernel

    本来想先增加python2kernel,只是还没有想好该怎么协调,可能会选择virtualenv+shell脚本来管理,我的win10上面就是这样处理的,但是隐约感觉不是最优的,先掠过。

    1. 环境需求
    • gcc
    • git
    • python3
    • pip
    • jupyter
      按照我们一路过来的话,是都满足的,如果不满足可以使用pacman来安装。
    2.Step-by-step:
    pip install jupyter-c-kernel
    git clone https://github.com/brendan-rius/jupyter-c-kernel.git
    cd jupyter-c-kernel
    jupyter-kernelspec install c_cspec/
    

    五、重复第三步登陆

    之后在jupyter的新建选项当中就有 C 选项,可以简单尝试一下:
    上个图吧!

    Paste_Image.png

    相关文章

      网友评论

        本文标题:四、Arch Linux Cheat Sheet (Jupyte

        本文链接:https://www.haomeiwen.com/subject/tbfcvttx.html