jupyter notebook 自定义配置


创建配置文件

1
jupyter notebook --generate-config

文件位置 ~/.jupyter/jupyter_notebook_config.py

设置密码

1
2
3
4
5
6
ipython
In [1]: from notebook.auth import passwd
In [2]: passwd()
Enter password:
Verify password:
Out[2]: 'sha1:67c9e60bb8b6:9ffede0825894254b2e042ea597d771089e11aed'

简单的配置实例

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
# Set options for certfile, ip, password, and toggle off
# browser auto-opening
c.NotebookApp.certfile = u'/absolute/path/to/your/certificate/mycert.pem'
c.NotebookApp.keyfile = u'/absolute/path/to/your/certificate/mykey.key'
# Set ip to '*' to bind on all interfaces (ips) for the public server
c.NotebookApp.ip = '*'
c.NotebookApp.password = u'sha1:67c9e60bb8b6:9ffede0825894254b2e042ea597d771089e11aed'
c.NotebookApp.open_browser = False

# It is a good idea to set a known, fixed port for server access
c.NotebookApp.port = 8001
c.ContentManager.root_dir = 'ipython' # ipython目录在~/ipython, 

设置工作目录
在home创建目录ipython:~/ipython,配置时只写目录名,不需要加/

1
c.ContentManager.root_dir = 'ipython' # ipython目录在~/ipython, 

启动notebook

1
jupyter notebook

notebook server地址:http://localhost:9999/tree

error

1
2
#PermissionError: [Errno 13] Permission denied: '/run/user/1001/jupyter/notebook_cookie_secret'
sudo rm -rf /run/user/1001/jupyter

resource