配置jupyter服务

1 生成配置文件

jupyter notebook --generate-config

以上命令会在用户目录下生成配置文件, 路径通常是: ~/.jupyter/jupyter_notebook_config.py, 该配置文件会在启动jupyter服务时生效.

2 修改配置文件

在生成的配置文件中加入配置项.

c.NotebookApp.ip = '*'              # 就是设置所有ip皆可访问  
c.NotebookApp.open_browser = False  # 禁止浏览器自动打开
c.NotebookApp.port = (port)         # jupyter使用端口

设置jupyter密码, 以下命令会引导密码设置, 并自动生成配置文件: ~/.jupyter/jupyter_notebook_config.json.

jupyter notebook password

3 配置kernel

jupyter服务不会自动包含anaconda创建的环境, 因此需要手动设置jupyter的kernel, 以便其找到已有的anaconda环境.

  • 查看已添加的kernel

jupyter kernelspec list

  • 添加kernel

(python) -m ipykernel install --name (kernel name)

  • 删除kernel

jupyter kernelspec remove (kernel name)

4 启动服务

  • 运行

jupyter notebook --allow-root

  • 后台运行

nohup jupyter notebook --allow-root &

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容