欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

jupyter 设置远程访问配置过程及问题的解决

程序员文章站 2022-01-20 10:04:59
...

很早之前试图将jupyter装在服务器上,但没有成功,就以为不行这样,然后不了了之。 最近同学在弄,成功了,我就又搞了一次。记录下,过程与怎么去解决遇到的问题的。

在服务器配好jupyter的环境及下载jupyter

这里就不说了,网上一搜一大篇

在服务器上的配置

  1. 生成jupyter的默认配置文件
	jupyter notebook --generate-config
  1. 生成密码(后面会用到)
    在命令行输入
	ipython

再输入

	from notebook.auth import passwd
	passwd()
  1. 输入你的密码并记住,得到一个**并复制下来。

    vim ~/.jupyter/jupyter_notebook_config.py

加入

c.NotebookApp.ip='*'
c.NotebookApp.password = u'复制的**'
c.NotebookApp.open_browser = False
c.NotebookApp.port =xxxx #自定义需后面访问的端口

4.遇到的问题(KeyError: ‘allow_remote_access’)

Traceback (most recent call last):
File “/usr/local/lib/python3.5/dist-packages/traitlets/traitlets.py”, line 528, in get
value = obj._trait_values[self.name]
KeyError: ‘allow_remote_access’
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File “/usr/local/lib/python3.5/dist-packages/notebook/notebookapp.py”, line 869, in _default_allow_remote
addr = ipaddress.ip_address(self.ip)
File “/usr/lib/python3.5/ipaddress.py”, line 54, in ip_address
address)
ValueError: ‘’ does not appear to be an IPv4 or IPv6 address
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File “/usr/local/bin/jupyter-notebook”, line 11, in
sys.exit(main())
File “/usr/local/lib/python3.5/dist-packages/jupyter_core/application.py”, line 266, in launch_instance
return super(JupyterApp, cls).launch_instance(argv=argv, **kwargs)
File “/usr/local/lib/python3.5/dist-packages/traitlets/config/application.py”, line 657, in launch_instance
app.initialize(argv)
File “”, line 2, in initialize
File “/usr/local/lib/python3.5/dist-packages/traitlets/config/application.py”, line 87, in catch_config_error
return method(app, *args, **kwargs)
File “/usr/local/lib/python3.5/dist-packages/notebook/notebookapp.py”, line 1629, in initialize
self.init_webapp()
File “/usr/local/lib/python3.5/dist-packages/notebook/notebookapp.py”, line 1379, in init_webapp
self.jinja_environment_options,
File “/usr/local/lib/python3.5/dist-packages/notebook/notebookapp.py”, line 158, in init
default_url, settings_overrides, jinja_env_options)
File “/usr/local/lib/python3.5/dist-packages/notebook/notebookapp.py”, line 251, in init_settings
allow_remote_access=jupyter_app.allow_remote_access,
File “/usr/local/lib/python3.5/dist-packages/traitlets/traitlets.py”, line 556, in get
return self.get(obj, cls)
File “/usr/local/lib/python3.5/dist-packages/traitlets/traitlets.py”, line 535, in get
value = self._validate(obj, dynamic_default())
File “/usr/local/lib/python3.5/dist-packages/notebook/notebookapp.py”, line 872, in _default_allow_remote

在配置文件中加入

c.NotebookApp.allow_remote_access = True

tip

如果你是阿里云,增加一个你要访问的端口

bye!!

相关标签: jupyter