Anaconda prompt运行打开jupyter notebook 指令出错

一、打不开jupyter notebook网页

报错如下:

Traceback (most recent call last):

File "D:\anaconda3\lib\site-packages\notebook\traittypes.py", line 235, in _resolve_classes

klass = self._resolve_string(klass)

File "C:\Users\DELL\AppData\Roaming\Python\Python39\site-packages\traitlets\traitlets.py", line 2015, in _resolve_string

return import_item(string)

File "C:\Users\DELL\AppData\Roaming\Python\Python39\site-packages\traitlets\utils\importstring.py", line 33, in import_item

module = import (package, fromlist=[obj])

ModuleNotFoundError: No module named 'jupyter_server.contents'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):

File "D:\anaconda3\Scripts\jupyter-notebook-script.py", line 10, in

sys.exit(main())

File "C:\Users\DELL\AppData\Roaming\Python\Python39\site-packages\jupyter_core\application.py", line 283, in launch_instance

super().launch_instance(argv=argv, **kwargs)

File "C:\Users\DELL\AppData\Roaming\Python\Python39\site-packages\traitlets\config\application.py", line 1073, in launch_instance

app = cls.instance(**kwargs)

File "C:\Users\DELL\AppData\Roaming\Python\Python39\site-packages\traitlets\config\configurable.py", line 583, in instance

inst = cls(*args, **kwargs)

File "C:\Users\DELL\AppData\Roaming\Python\Python39\site-packages\traitlets\traitlets.py", line 1292, in new

inst.setup_instance(*args, **kwargs)

File "C:\Users\DELL\AppData\Roaming\Python\Python39\site-packages\traitlets\traitlets.py", line 1335, in setup_instance

super(HasTraits, self).setup_instance(*args, **kwargs)

File "C:\Users\DELL\AppData\Roaming\Python\Python39\site-packages\traitlets\traitlets.py", line 1311, in setup_instance

init(self)

File "D:\anaconda3\lib\site-packages\notebook\traittypes.py", line 226, in instance_init

self._resolve_classes()

File "D:\anaconda3\lib\site-packages\notebook\traittypes.py", line 238, in _resolve_classes

warn(f"{klass} is not importable. Is it installed?", ImportWarning)

TypeError: warn() missing 1 required keyword-only argument: 'stacklevel'

运行jupyter notebook的软件会出现闪退现象

二、尝试更新

1.更新 Jupyter 相关的模块:使用 Anaconda 自带的包管理器 conda 来更新 Jupyter 相关的模块,尤其是 jupyter_server。在 Anaconda Prompt 中运行以下命令来更新:

bash 复制代码
conda update jupyter_server

更新完运行还是报错

2.重新安装 Jupyter:

bash 复制代码
conda install jupyter

更新完运行还是报错

三、成功解决

感谢 http://t.csdnimg.cn/usTk8

运行以下命令解决问题:

bash 复制代码
pip uninstall traitlets
pip install traitlets==5.9.0

成功打开

四、重新修改一下默认保存路径

1.查找默认配置文件地址

运行win+r

输入jupyter notebook --generate-config

再输入y,回车

2.在文件资源管理中打开C:\Users\DELL\.jupyter\

用记事本打开,ctrl+f查找c.NotebookApp.notebook_dir ,删除注释,加入保存路径,保存

相关推荐
luoluoal5 分钟前
基于深度学习的web端多格式纠错系统(源码+文档)
python·mysql·django·毕业设计·源码
深蓝海拓11 分钟前
PySide6从0开始学习的笔记(二十七) 日志管理
笔记·python·学习·pyqt
天天进步201520 分钟前
Python全栈项目:实时数据处理平台
开发语言·python
Tipriest_20 分钟前
Python中is关键字详细说明,比较的是地址还是值
开发语言·python
sheji341621 分钟前
【开题答辩全过程】以 基于Python的餐饮统计系统的设计和实 现为例,包含答辩的问题和答案
开发语言·python
遨游xyz34 分钟前
排序-快速排序
开发语言·python·排序算法
iFeng的小屋1 小时前
【2026年新版】Python根据小红书关键词爬取所有笔记数据
笔记·爬虫·python
m0_561359671 小时前
使用Python处理计算机图形学(PIL/Pillow)
jvm·数据库·python
dongdonglele5211 小时前
ros2环境安装
windows
LeonDL1681 小时前
基于YOLO11深度学习的衣物识别系统【Python源码+Pyqt5界面+数据集+安装使用教程+训练代码】【附下载链接】
人工智能·python·pyqt5·yolo数据集·yolo11数据集·yolo11深度学习·衣物识别系统