文章目录
折腾挺久的,先上一下效果图
查看变量在jupyter选项卡里面,点击view as Array就会出现右侧的sciview窗格,显示这个窗格需要设置一下
启动kernel会比较慢,需要稍微等一会儿。
下面是步骤
1.win + R 使用pip命令安装jupyter notebook
不知道只安装jupyter是不是就可以了,我安装的jupyter notebook,里面是包含jupyter的
pip install jupyter notebook
安装时间比较长,安装好之后就可以尝试在控制台启动,注意,是win+R控制台。之前我以为pip安装的东西都是包或者库,只能在python控制台下面使用,走了很多弯路
安装好之后,还可以查看jupyter支持哪些命令
jupyter notebook --help
jupyter notebook # start the notebook
jupyter notebook --certfile=mycert.pem # use SSL/TLS certificate
jupyter notebook password # enter a password to protect the server
2. 启动jupyter notebook
jupyter notebook

3. 新建一个notebook文件,配置jupyter server和解释器


只输入http://localhost:8888,后面运行时候会出现弹窗,提示输入口令或密码

避免每次token生成不一样,我设置了密码。123456 是我设置的密码
设置方法如下:
找到jupyter配置文件目录
jupyter --config
转到目录中编辑配置文件,找到这一行
# c.NotebookApp.token =
4. 运行jupyter文件
在需要运行的行前面写#%%,左侧就会出现一个绿色的小箭头,可以点击运行或者调试,也可以使用提示的快捷方式 ctrl + enter 运行
4.一些错误
- 启动idea 首次启动jupyter notebook的时候成功运行代码,但是关闭后重启就会报如下错误

Kernel does not exist: 96b59d42-d81e-471c-8ef9-63a61a963a16
[W 11:15:08.362 NotebookApp] No session ID specified[W 11:15:08.362 NotebookApp] 404 GET /api/kernels/96b59d42-d81e-471c-8ef9-63a61a963a16/channels (127.0.0.1): Kernel does not exist: 96b59d42-d81e-471c-8ef9-63a61a963a16[W 11:15:08.369 NotebookApp] 404 GET /api/kernels/96b59d42-d81e-471c-8ef9-63a61a963a16/channels (127.0.0.1) 9.02ms referer=None然后我输入了 ctrl+C终止运行,关闭了0个kernel进程
[I 11:21:39.267 NotebookApp] Interrupted...
[I 11:21:39.268 NotebookApp] Shutting down 0 kernels
一启动jupyter notebook就生成了这三个文件

用记事本打开nbserver-2280.json文件,会发现123456并没有进入到password字段中,而是被放入到了token字段。这个时候在pycharm中点击

这时候会重新提示输入密码
输入密码之后保存就对了。
有时候报错找不到kernel,直接来清空这个目录重启jupyter notebook可以解决很多问题
发布者:全栈程序员-站长,转载请注明出处:https://javaforall.net/216780.html原文链接:https://javaforall.net
