[挖坑笔记]Centos7折腾Jupyter Notebook

最近学Python 偶然间发现了Jupyter Notebook这个神奇的工具 于是给自己挖了个坑

Anaconda版本安装

Anaconda已经自动为你安装了Jupter Notebook及其他工具,还有python中超过180个科学包及其依赖项。
你可以通过进入Anaconda的官方下载页面自行选择下载

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

如果提示bunzip2: command not found那么我们安装下bunzip2即可

yum install -y bzip2

常规来说,安装了Anaconda发行版时已经自动为你安装了Jupyter Notebook的,但如果没有自动安装,那么就在终端(Linux或macOS的“终端”,Windows的“Anaconda Prompt”,以下均简称“终端”)中输入以下命令安装:

conda install jupyter notebook

如果提示conda command not found那么我们执行下下面的代码即可

source ~/.bash_profile

使用PIP安装

我自己还没折腾明白先不写了

运行Jupyter Notebook

默认端口启动

jupyter notebook

报错

[root@iZj6c60t3bjdrsrm8ojftuZ ~]# jupyter notebook
[I 21:17:23.827 NotebookApp] Writing notebook server cookie secret to /run/user/0/jupyter/notebook_cookie_secret
Traceback (most recent call last):
  File "/root/anaconda3/bin/jupyter-notebook", line 11, in <module>
    sys.exit(main())
  File "/root/anaconda3/lib/python3.7/site-packages/jupyter_core/application.py", line 266, in launch_instance
    return super(JupyterApp, cls).launch_instance(argv=argv, **kwargs)
  File "/root/anaconda3/lib/python3.7/site-packages/traitlets/config/application.py", line 657, in launch_instance
    app.initialize(argv)
  File "</root/anaconda3/lib/python3.7/site-packages/decorator.py:decorator-gen-7>", line 2, in initialize
  File "/root/anaconda3/lib/python3.7/site-packages/traitlets/config/application.py", line 87, in catch_config_error
    return method(app, *args, **kwargs)
  File "/root/anaconda3/lib/python3.7/site-packages/notebook/notebookapp.py", line 1630, in initialize
    self.init_webapp()
  File "/root/anaconda3/lib/python3.7/site-packages/notebook/notebookapp.py", line 1407, in init_webapp
    self.http_server.listen(port, self.ip)
  File "/root/anaconda3/lib/python3.7/site-packages/tornado/tcpserver.py", line 151, in listen
    sockets = bind_sockets(port, address=address)
  File "/root/anaconda3/lib/python3.7/site-packages/tornado/netutil.py", line 174, in bind_sockets
    sock.bind(sockaddr)
OSError: [Errno 99] Cannot assign requested address

解决方案:添加启动参数

jupyter notebook --ip=0.0.0.0 --no-browser --allow-root

出现如下信息说明启动成功

[root@iZj6c60t3bjdrsrm8ojftuZ ~]# jupyter notebook --ip=0.0.0.0 --no-browser --allow-root
[I 21:20:12.204 NotebookApp] JupyterLab extension loaded from /root/anaconda3/lib/python3.7/site-packages/jupyterlab
[I 21:20:12.204 NotebookApp] JupyterLab application directory is /root/anaconda3/share/jupyter/lab
[I 21:20:12.205 NotebookApp] Serving notebooks from local directory: /root
[I 21:20:12.206 NotebookApp] The Jupyter Notebook is running at:
[I 21:20:12.206 NotebookApp] http://(iZj6c60t3bjdrsrm8ojftuZ or 127.0.0.1):8888/?token=d547f7ee68511fe93f6697ece677ce730fc67ba2c7d0343e
[I 21:20:12.206 NotebookApp] Use Control-C to stop this server and shut down all kernels (twice to skip confirmation).
[C 21:20:12.210 NotebookApp] 

    To access the notebook, open this file in a browser:
        file:///run/user/0/jupyter/nbserver-30440-open.html
    Or copy and paste one of these URLs:
        http://(iZj6c60t3bjdrsrm8ojftuZ or 127.0.0.1):8888/?token=d547f7ee68511fe93f6697ece677ce730fc67ba2c7d0343e

访问http://(iZj6c60t3bjdrsrm8ojftuZ or 127.0.0.1):8888/?token=d547f7ee68511fe93f6697ece677ce730fc67ba2c7d0343e即可访问您的页面(注意修改地址)。
使用过程中不要关闭终端如果想要关闭后继续运行可以使用screen

screen -S jupyter  #创建一个jupyter的窗口
jupyter notebook --ip=0.0.0.0 --no-browser --allow-root  ##执行命令
ctrl+a+z  #将程序放到后台退出

给TA打赏
共{{data.count}}人
人已打赏
教程

京东抢购????

2019-6-17 1:53:47

教程

Forsaken Mail一个即收即毁的临时邮箱系统

2019-7-28 22:06:48

0 条回复 A文章作者 M管理员
    暂无讨论,说说你的看法吧
个人中心
购物车
优惠劵
今日签到
有新私信 私信列表
搜索