【教程】jupyter notebook使用最全教程
1. 安装
pip install jupyter
2. 使用
- 在工程目录下执行命令,自动打开浏览器
jupyter notebook
- 浏览器不自动打开, 此时在浏览器地址栏手动输入 192.168.111.211(本机ip)或localhost或127.0.0.1:8888(端口号)
jupyter notebook --no-browser
- 也可以指定需要监听的ip与端口号port
jupyter notebook --no-browser --ip=0.0.0.0 --port=8888
- 关闭
两次ctrl + C
3. 配置远程访问+密码
- 生成配置文件
jupyter notebook --generate-config
- 打开ipython,创建密码
In [1]: from notebook.auth import passwd
In [2]: passwd()
Enter password: (输入访问密码)
Verify password: (确认访问密码)
Out[2]: 'sha1:5abb4ceff757:755ad24707eedf644e07c34ec099d0485f9927a5'
复制密钥串,待会需要用到
- 修改第一步生成的配置文件
vi ~/.jupyter/jupyter_notebook_config.py
在文件头部加入:
c.NotebookApp.ip='*' # 就是设置所有ip皆可访问
c.NotebookApp.password = u'刚才的密钥串'
c.NotebookApp.open_browser = False # 禁止自动打开浏览器
c.NotebookApp.port =8888 #指定一个端口
- 启动,并输入密码登录
jupyter notebook
4. 虚拟环境+jupyter notebook
- 进入虚拟环境
source virtualwork/bin/activate
- 安装ipykernel
pip install ipykernel
- 将虚拟环境加入到ipykernel
python -m ipykernel install --user --name=virtualwork
- 启动jupyter notebook,就可以更改kernel了
5. 管理kernel
- 查看已经安装的kernel
jupyter kernelspec list
- 卸载指定kernel
jupyter kernelspec remove kernel名称
6. 卸载
pip uninstall jupyter-core jupyter-client qtconsole jupyter-console nbformat nbconvert notebook jupyter -y
7. 主要参考博客
[1] https://blog.youkuaiyun.com/Yuki_play/article/details/87646947
[2] https://zhuanlan.zhihu.com/p/27339792
[3] https://blog.youkuaiyun.com/weixin_40539892/article/details/80940885
[4] https://blog.youkuaiyun.com/fontthrone/article/details/84616937