脚本之家,脚本语言编程技术及教程分享平台!
分类导航

Python|VBS|Ruby|Lua|perl|VBA|Golang|PowerShell|Erlang|autoit|Dos|bat|

服务器之家 - 脚本之家 - Python - jupyter notebook远程访问不了的问题解决方法

jupyter notebook远程访问不了的问题解决方法

2021-08-24 00:01陈 超 Python

这篇文章主要介绍了jupyter notebook远程访问不了的问题解决方法,文中通过示例代码介绍的非常详细,对大家的学习或者工作具有一定的参考学习价值,需要的朋友们下面随着小编来一起学习学习吧

jupyter notebook非常方便,想在服务器上面搭建一个,但是访问不了。

(一)首先是安装jupyter notebook,

  1. pip install jupyter

如果pip安装报错,缺少sqlite的库,那么请安装

  1. sudo apt-get install libsqlite3-dev

然后需要“重新编译python”,再通过pip安装(python3.x则不需要安装pysqlite)

  1. pip install pysqlite

(二)启动jupyter

  1. jupyter notebook

其实这时候,local如果有browser的话,就可以输入访问了,但是没有,所以需要远程访问: http://ip:8888,发现访问不了

(三)配置远程访问jupyter

1)首先输入ipython生成秘钥

  1. $ ipython
  2. from notebook.auth import passwd
  3. passwd()

设定一个密码,会生成一个sha1的秘钥,如下图:

jupyter notebook远程访问不了的问题解决方法

2)生成jupyter的config文件

  1. $ jupyter notebook --generate-config

这时候会生成配置文件,在 ~/.jupyter/jupyter_notebook_config.py

3)修改配置文件:~/.jupyter/jupyter_notebook_config.py

  1. $vim ~/.jupyter/jupyter_notebook_config.py

加入如下内容,其中sha1那一串秘钥是上面生成的那一串

  1. c.NotebookApp.ip='*'
  2. c.NotebookApp.password = u'sha1:f9030dd55bce:75fd7bbaba41be6ff5ac2e811b62354ab55b1f63'
  3. c.NotebookApp.open_browser = False
  4. c.NotebookApp.port =8888

如图:

jupyter notebook远程访问不了的问题解决方法

保存退出。

4)启动jupyter

  1. $jupyter notebook

jupyter notebook远程访问不了的问题解决方法

在远程电脑上,打开浏览器,输入:http://your-server-ip:8888

jupyter notebook远程访问不了的问题解决方法

需要输入密码,就是上面设置的那个密码,输入即可

jupyter notebook远程访问不了的问题解决方法

到此这篇关于jupyter notebook远程访问不了的问题解决方法的文章就介绍到这了,更多相关jupyter notebook远程访问内容请搜索服务器之家以前的文章或继续浏览下面的相关文章希望大家以后多多支持服务器之家!

原文链接:https://blog.csdn.net/cc1949/article/details/79095494

延伸 · 阅读

精彩推荐