安装配置远程jupyter notebook(原ipython notebook)


在新版本的ipython中,将逐步不再使用ipython notebook这个名字,现在已经把通过浏览器远程使用notebook迁移到了jupeter notebook底下。如果继续按照以前的办法配置远程ipython notebook,多半会发现找不到给ipython notebook服务器创建的配置文件
/profile_nbserver/ipython_notebook_config.py。
下面是jupyter notebook远程服务器的配置教程。

1.创建登陆密码

先在服务器端启动远程ipython,生成自定义密码的sha1

In [1]: from IPython.lib import passwd
In [2]: passwd()
Enter password:
Verify password:
Out[2]: ‘sha1:67c9e60bb8b6:9ffede0825894254b2e042ea597d771089e11aed‘
... prompt'''

此时输入密码和确认密码,第六步远程登陆就是用这个密码。同时牢记sha1,下面的配置要用到。

2.创建自签名证书

使用openssl创建一个自签名证书,由于是自签名所以浏览器会提示警告,选择信任exception即可。如果不想引起警告,需具备合格证compliant certificate,可参照tutorial

$ openssl req -x509 -nodes -days 365 -newkey rsa:1024 -keyout mycert.pem -out mycert.pem

记住mycert.pem的位置,一会要用到,可通过pwd查看

3.创建jupyter notebook服务器

jupyter notebook --generate-config

命令行会有输出,告诉你生成的文件在哪里.
默认位置在~/.jupyter/jupyter_notebook_config.py
此时可以将 mycert.pem 证书移到jupyter notebook的文件夹,将相关的东西放在一起。

mv mycert.pem .jupyter

4.修改配置文件

生成的配置文件在 /home/yourname/.jupyter/jupyter_notebook_config.py
打开配置文件,把下面cerfile的路径以及password里边sha1后边的内容替换为自己的,然后粘贴到配置文件的最底下,保存退出。注意使用英文输入法复制粘贴,要不英文单引号对’'会被替换为中文单引号对‘’。

c = get_config()

# Notebook config
c.NotebookApp.certfile = u'/home/yourname/.jupyter/mycert.pem'
c.NotebookApp.ip = '*'
c.NotebookApp.open_browser = False
c.NotebookApp.password = u'sha1:42dd2962e4eb:4e258d7a934d8971e4b26b460ab27276a9d082b0'
# It's a good idea to put it on a known, fixed port
c.NotebookApp.port = 9999

5.启动jupyter notebook服务器

 jupyter notebook

然后看到下面输出

 The Jupyter Notebook is running at: https://[all ip addresses on your system]:9999/

6.远程连接jupyter notebook

以上操作都是在服务器上的操作,现在打开浏览器,输入
https://192.168.56.101:9999
此时要求输入密码,这个密码就是刚才创建sha1时输入的密码(不是sha1)。

其他的和普通的jupyter notebook一样的操作了。
注意,这里192.168.56.101是我服务器上的ubuntu开启的地址,请换成你的远程地址。

7.迁移以前的ipython notebook服务器配置文件

如果你需要迁移以前的ipython notebook配置文件,可以使用命令

jupyter migrate

这样配置文件会被转移到~/.jupyter文件夹底下。

8.如何添加kernel

现在以已有Python 2,需要添加Python 3为例:

pip3 install ipykernel --user
python3 -m ipykernel install --user

重启jupyter即可。

9.安装jupyter插件管理器


pip install jupyter_contrib_nbextensions --user

jupyter contrib nbextension install --user

pip install jupyter_nbextensions_configurator --user

jupyter nbextensions_configurator enable --user

第一个和第二个命令安装了用于管理安装插件的工具,第二个和第三个命令是安装激活用于配置扩展管理的工具

10.如何支持markdown显示

首先需要安装一个扩展工具包

pip install notedown --user

然后修改配置文件

vim ~/.jupyter/jupyter_notebook_config.py

增加以下内容并保存

c.NotebookApp.contents_manager_class = ‘notedown.NotedownContentsManager’

最后重启jupyter notebook 服务就可以了~

参考:
-http://stackoverflow.com/questions/31962862/ipython-ipython-notebook-config-py-missing
-http://blog.csdn.net/suzyu12345/article/details/51037905
-http://jupyter.readthedocs.io/en/latest/migrating.html
Jupyter notebook 里面没有python3怎么办?
Jupyter插件安装及其虚拟多环境创建

  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值