zoukankan      html  css  js  c++  java
  • [转]Linux中python3.6+ipython+Jupyter Notebook环境

    python3.6安装


    1. 下载python安装包,这里下载的最新的3.6.1版本
      https://www.python.org/ftp/python/3.6.1/
    2. 将安装包上传到服务器并解压
    tar zxvf Python-3.6.1.tgz
    
    1. 安装python
    cd Python-3.6.1
    ./configure --prefix=/usr/local/python-3.6.1     #重要,指定python的安装路径,可以自己设置。
    make
    sudo make install
    
    1. 修改python的软链接 (建立软链接,变为全局)
    sudo ln -s /usr/local/python-3.6.1/bin/python3.6 /usr/bin/python
    
    1. 查看python版本,发现已经改变
      python
       
       

    ipython安装


    1. 下载ipython,并上传到服务器
      http://archive.ipython.org/release/6.0.0/
    2. 解压
    tar -zxvf ipython-6.0.0.tar.gz
    
    1. 进入解压的ipython目录并执行如下命令进行安装
    python setup.py install
    
    1. 进行链接
    ln -s /usr/local/python-3.6.1/bin/ipython /usr/sbin/ipython
    
    1. 检查ipython是否安装成功
    ipython
    
     
     

    此时发现提示说有模板缺失,使用pip进行安装。

    pip install traitlets
    

    再执行ipython进行检验,发现还是某个模板缺失


     
     

    继续用pip进行安装,知道执行ipython时出现如下界面,代表安装成功。


     
     

    Jupyter Notebook安装


    Jupyter Notebook(此前被称为 IPython notebook)是一个交互式笔记本,支持运行 40 多种编程语言。Notebook是一个数据分析和编写代码的好工具。它的核心在于展示与快速迭代。
    摘自: 知乎为什么使用jupyter?
    看完知乎的这个回答会对jupyter有个大概的认知,接下来进行安装。

    1. 安装jupyter notebook
    pip install jupyter notebook 
    
    1. 启动notebook
    jupyter notebook
    

    此时报错,不建议用root运行启动命令:

    [I 16:23:40.195 NotebookApp] Writing notebook server cookie secret to /root/.local/t
    [C 16:23:40.213 NotebookApp] Running as root is not recommended. Use --allow-root t.
    

    解决方法:

    • 修改配置文件,执行jupyter notebook --generate-config即可初始化配置文件来,但是这里要加入--allow-root才行
    [root@localhost ~]# jupyter notebook --generate-config --allow-root
    Writing default config to: /root/.jupyter/jupyter_notebook_config.py
    
    • 创建一个密码:[这样就不用每次复制URL地址]
    [root@localhost ~]# ipython
    Python 3.6.1 (default, May 25 2017, 16:49:43) 
    Type 'copyright', 'credits' or 'license' for more information
    IPython 6.0.0 -- An enhanced Interactive Python. Type '?' for help.
    In [1]:  from notebook.auth import passwd 
    In [2]: passwd()
    Enter password: 
    Verify password: 
    Out[2]: 'sha1:f6ac161e9215:dc0eb8c8d43b74e32bb03db161e3261ea5d7c297'
    

    将这里的 ```
    'sha1:f6ac161e9215:dc0eb8c8d43b74e32bb03db161e3261ea5d7c297'

     *  修改配置文件中的IP地址、工作目录、并添加一个认证密码:
    

    [root@localhost .jupyter]# vim /root/.jupyter/jupyter_notebook_config.py

    修改权限
    

    c.NotebookApp.allow_root = False

    去掉行注释,并修改成True即可解决root权限运行的问题。

    设置,外部可访问
    

    c.NotebookApp.ip = 'localhost'

    去掉注释,并把localhost改成0.0.0.0,这样就可以外部访问了,默认只有在本机可以访问的;
    c.NotebookApp.ip = '0.0.0.0'

    设置notebook的工作目录
    

    c.NotebookApp.notebook_dir = u''

    改成如下,这样就会默认把notebook上创建的文件保存到指定目录下;需要事先创建。
    c.NotebookApp.notebook_dir = u'/opt/jupyter'

    加入密码
    

    c.NotebookApp.password = u''

    加入上面创建的密码:
    c.NotebookApp.password = u'sha1:f6ac161e9215:dc0eb8c8d43b74e32bb03db161e3261ea5d7c297'

    3. 进入notebook界面
    再次执行启动命令,出现如下信息,表示成功
    

    [root@localhost .jupyter]# jupyter-notebook
    [I 18:09:58.194 NotebookApp] Serving notebooks from local directory: /opt/jupyter
    [I 18:09:58.194 NotebookApp] 0 active kernels
    [I 18:09:58.194 NotebookApp] The Jupyter Notebook is running at:
    http://0.0.0.0:8888/bookApp]

    在浏览器输入如下网址:http://你的ip:8888
    可以看到如下界面:
    ![](http://upload-images.jianshu.io/upload_images/3832654-94a8ebba9ef56652.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)
    
    **参考:**
    [官方文档](https://jupyter.readthedocs.io/en/latest/install.html)
    [centos7安装notebook 5.0.0的方法](https://www.58jb.com/html/146.html)


    作者:夏无忧阳
    链接:https://www.jianshu.com/p/0133f79a12db
    来源:简书
    简书著作权归作者所有,任何形式的转载都请联系作者获得授权并注明出处。
     
     

    vim /etc/systemd/system/shadowsocks.service

    systemctl daemon-reload

    systemctl status shadowsocks -l

    systemctl start shadowsocks

  • 相关阅读:
    详解Paint的setPathEffect(PathEffect effect)
    详解Paint的setMaskFilter(MaskFilter maskfilter)
    用TextPaint来绘制文字
    详解Paint的setXfermode(Xfermode xfermode)
    详解Paint的setColorFilter(ColorFilter filter)
    ASP.NET Core 高性能开发最佳实践
    疫苗,为啥还要等这么久?
    物联网行业的基本系统架构
    超级强大的学习方法--费曼技巧
    衡水中学学霸李江珊,高考英语149分,从不刷题的她如何做到的
  • 原文地址:https://www.cnblogs.com/xuyuan77/p/10579264.html
Copyright © 2011-2022 走看看