garnet@DESKTOP-DH5TCF8:~/.pip$ jupyter lab --generate-config
Writing default config to: /home/garnet/.jupyter/jupyter_notebook_config.py
编辑配置文件
只说明几个重要字段.
网络设置
## The IP address the notebook server will listen on.
c.NotebookApp.ip = '0.0.0.0'
## The port the notebook server will listen on.
c.NotebookApp.port = 8888
## Whether to allow the user to run the notebook as root.
c.NotebookApp.allow_root = True
目录
实验环境的根目录.
## The directory to use for notebooks and kernels.
c.NotebookApp.notebook_dir = '/home/user/notebook'
密码
首先在Python环境中查看指定密码加密后的结果:
garnet@DESKTOP-DH5TCF8:~$ python
Python 3.6.5 |Anaconda, Inc.| (default, Apr 29 2018, 16:14:56)
[GCC 7.2.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> from notebook.auth import passwd
>>> passwd()
Enter password:
Verify password:
'sha1:6cd6bac1f498:58710eca31eebd1c3937125135a81836b43e9916'
>>>
这里输入的密码是123456, 得到加密的结果. 将加密后的字符串写入jupyter的配置文件中:
## Hashed password to use for web authentication.
#
# To generate, type in a python/IPython shell:
#
# from notebook.auth import passwd; passwd()
#
# The string should be of the form type:salt:hashed-password.
c.NotebookApp.password = 'sha1:6cd6bac1f498:58710eca31eebd1c3937125135a81836b43e9916'
然后在浏览器里第一次打开实验环境时, 就需要输入密码进入.
浏览器
是否在启动环境成功后, 自动在浏览器里打开实验环境. 默认是打开的, 最好关闭掉.
## Whether to open in a browser after starting. The specific browser used is
# platform dependent and determined by the python standard library `webbrowser`
# module, unless it is overridden using the --browser (NotebookApp.browser)
# configuration option.
c.NotebookApp.open_browser = False