Linux Anaconda配置Jupyter Notebook远程访问

44 篇文章 6 订阅

前面我们安装过Anaconda了,参考

1. 安装ipython, jupyter

pip install ipython  
pip install jupyter

2.生成配置文件

dm@zerotech-All-Series:~$ jupyter notebook --generate-config

3.生成密码
dm@zerotech-All-Series:~$ ipython

Python 3.6.6 (default, Oct 21 2016, 21:37:19)   
Type 'copyright', 'credits' or 'license' for more information  
IPython 6.2.1 -- An enhanced Interactive Python. Type '?' for help. 
In [1]: from notebook.auth import passwd 
In [2]: passwd()  
Enter password:   #输入个密码,后续登录的时候需要
Verify password:   
Out[2]: 'sha1:43b95b731276:5d330ee6f6054613b3ab4cc59c5048ff7c70f549' 
In [3]:  

4.修改配置文件
dm@zerotech-All-Series:~$ vim /home/dm/.jupyter/jupyter_notebook_config.py

c.NotebookApp.ip='*' #设置访问notebook的ip,*表示所有IP,这里设置ip为都可访问
c.NotebookApp.notebook_dir = '/home/ozh/share'#共享目录
c.NotebookApp.password = u'sha1:5df252f58b7f:bf65d53125bb36c085162b3780377f66d73972d1' #填写刚刚生成的密文  
c.NotebookApp.open_browser = False # 禁止notebook启动时自动打开浏览器(在linux服务器一般都是ssh命令行访问,没有图形界面的。所以,启动也没啥用)  
c.NotebookApp.port =8899 #指定访问的端口,默认是8899  

c.NotebookApp.allow_remote_access = True


5.启动jupyter notebook
 

dm@zerotech-All-Series:~$ jupyter notebook

6.在浏览器里输入你的地址 http://IP:8899/,然后输入密码,就能看到你共享的目录

问题1:ImportError: cannot import name 'create_prompt_application
解决:pip install 'prompt-toolkit==1.0.15'

问题2:

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 <module>
    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 "<decorator-gen-7>", 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

解决:

vi ~/.jupyter/jupyter_notebook_config.py
添加如下代码行:
c.NotebookApp.allow_remote_access = True

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值