1、生成配置文件
(windows在cmd下|linux在终端),输入jupyter notebook --generate-config回车,会生成一个jupyter_notebook_config.py的配置文件,这个文件在用户目录下~/.jupyter/jupyter_notebook_config.py
2、生成密码
打开ipython(win系统下如果配置过环境变量的,可直接在cmd输入ipython),
In [1]: from notebook.auth import passwd
In [2]: passwd()
Enter password: --输入你的密码(不要奇怪是密文看不见)
Verify password: --确认密码
Out[2]: 'xxxxxxxxxxxxxxxxxxxxxxxxxxxx' --这是一串秘钥,请复制
3、修改配置文件
把第一步生成的配置文件用记事本打开,按照如下修改
c.NotebookApp.ip='*' ---任意IP访问
c.NotebookApp.password = xxx ---刚才复制的那个密文
c.NotebookApp.open_browser = False ---是否自动打开浏览器
c.NotebookApp.port =8888 --随便指定一个端口
4、重启jupyter
注意:
如果无法访问可能是防火墙的问题,如果可以访问,但是无法运行代码,可能是配置文件错了