生产环境使用 Fedora 28, 并且需要搭建一个 Jupyter 的notebook 方便使用,所搭建的Jupyter 支持单人远程 密码访问

1. 安装

安装 Jupyter , 出错

[root@dhcp-- ~]# pip install jupyter
WARNING: Running pip install with root privileges is generally not a good idea. Try `pip install --user` instead.
.
.
.
running install
running build
running build_py
creating build
creating build/lib.linux-x86_64-2.7
copying scandir.py -> build/lib.linux-x86_64-2.7
running build_ext
building '_scandir' extension
creating build/temp.linux-x86_64-2.7
gcc -pthread -fno-strict-aliasing -O2 -g -pipe -Wall -Werror=format-security -Wp,-D_FORTIFY_SOURCE= -fexceptions -fstack-protector-strong --param=ssp-buffer-size= -grecord-gcc-switches -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -m64 -mtune=generic -D_GNU_SOURCE -fPIC -fwrapv -DNDEBUG -O2 -g -pipe -Wall -Werror=format-security -Wp,-D_FORTIFY_SOURCE= -fexceptions -fstack-protector-strong --param=ssp-buffer-size= -grecord-gcc-switches -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -m64 -mtune=generic -D_GNU_SOURCE -fPIC -fwrapv -fPIC -I/usr/include/python2. -c _scandir.c -o build/temp.linux-x86_64-2.7/_scandir.o
gcc: error: /usr/lib/rpm/redhat/redhat-hardened-cc1: No such file or directory
error: command 'gcc' failed with exit status ----------------------------------------
Command "/usr/bin/python2 -u -c "import setuptools, tokenize;__file__='/tmp/pip-build-8KqVrv/scandir/setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" install --record /tmp/pip-IrivkV-record/install-record.txt --single-version-externally-managed --compile" failed with error code in /tmp/pip-build-8KqVrv/scandir/
You are using pip version 9.0., however version 10.0. is available.
You should consider upgrading via the 'pip install --upgrade pip' command.

安装 redhat-rpm-config

[root@dhcp-- ~]# yum install redhat-rpm-config

安装 python-devel

[root@dhcp-- ~]# yum install python-devel

安装 notebook

[root@dhcp-- ~]# pip install notebook

2. 运行

生成token 运行:

[root@dhcp-- ~]# jupyter notebook --allow-root
[I ::13.108 NotebookApp] Serving notebooks from local directory: /root
[I ::13.108 NotebookApp] active kernels
[I ::13.108 NotebookApp] The Jupyter Notebook is running at:
[I ::13.108 NotebookApp] http://localhost:8888/?token=60bbeb5c2ef4a8c0e15cfcb85588e265a185b46949e051e7

生成配置文件:

[root@dhcp-- ~]# jupyter notebook --generate-config
Writing default config to: /root/.jupyter/jupyter_notebook_config.py

3. 配置

(1)在配置文件中配置密码:

c.NotebookApp.password = u'sha1:12a39cedb875:c97d0285f90cec397fffe96f11e5ef5e56e90fa2'

其中:加密使用

from notebook.auth import passwd  中 password 方法进行加密
可以在 python shell 中生成 或者直接使用:
[root@dhcp-- ~]# jupyter notebook password

设置密码,并直接写到配置文件中

如果没有设置密码 可以使用 jupyter notebook list 命令来查看 token 从而进行访问。

(2)允许所有ip地址访问

# Set ip to '*' to bind on all interfaces (ips) for the public server
c.NotebookApp.ip = '*' or c.NotebookApp.ip = '0.0.0.0' (2020年4月20日更新)
c.NotebookApp.password = u'sha1:bcd259ccf...<your hashed password here>'
c.NotebookApp.open_browser = False # It is a good idea to set a known, fixed port for server access
c.NotebookApp.port = 8888

(3)  保证 IPython Clusters 运行

[root@dhcp-- ~]# pip install ipyparallel

后台运行:

[root@dhcp-- ~]# nohup jupyter notebook --allow-root &

具体对 notebook 外观的修改,可以从源代码角度进行修改,进行定制,这里就不多讲了。

如果 需要添加 防火墙规则,可以根据实际需要的端口进行添加。

更多配置请参考:

https://jupyter-notebook.readthedocs.io/en/stable/public_server.html#securing-a-notebook-server

https://github.com/ipython/ipyparallel

https://jupyterhub.readthedocs.io/en/latest/

保持更新,转载请注明出处。

最新文章

  1. CentOS 7.0编译安装Nginx1.6.0+MySQL5.6.19+PHP5.5.14
  2. 自己写一个 jQuery 插件
  3. imx6 gpio irq
  4. String类的写时拷贝
  5. laravel where中多条件查询
  6. MongoDB (一) MongoDB 介绍
  7. SQL Server三种表连接原理
  8. sb 讲解 (!(~+[])+{})[--[~+&quot;&quot;][+[]]*[~+[]] + ~~!+[]]+({}+[])[[~!+[]]*~+[]]
  9. Android自定义DataTimePicker(日期选择器)
  10. NSRunLoop 详解
  11. C#中使用日志类,添加dll时出现错误
  12. java集合系列——Map之TreeMap介绍(九)
  13. IP地址简介
  14. The more, The Better
  15. 【Java】 剑指offer(50-1) 字符串中第一个只出现一次的字符
  16. Ajax 小实例
  17. C# 其他的Url 文件的路径转化为二进制流
  18. CCPC2018-湖南全国邀请赛 Solution
  19. java.lang.NoClassDefFoundError: weblogic/kernel/KernelStatus
  20. bzoj 2821 分块

热门文章

  1. Maven 入门——认识Maven结构
  2. 实现比较器接口IComparable&lt;T&gt;,让自定义类型数组也能排序
  3. JDK7与JDK8中HashMap的实现
  4. 基于Hadoop2.6.5(HA)的HBase2.0.5配置
  5. angularjs学习第二天笔记---过滤器
  6. [日常] C语言中的字符数组和字符串
  7. Oracle 临时表创建及删除
  8. PHP定界符&lt;&lt;&lt;eof 使用
  9. WEB服务器、应用程序服务器、HTTP服务器的区别
  10. 排序算法(10)--Distribution Sorting--分布排序[2]--Radix Sort--基数排序