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 ,删除注释,加入保存路径,保存

相关推荐
Yan-英杰15 分钟前
百度搜索和文心智能体接入DeepSeek满血版——AI搜索的新纪元
图像处理·人工智能·python·深度学习·deepseek
weixin_307779131 小时前
Azure上基于OpenAI GPT-4模型验证行政区域数据的设计方案
数据仓库·python·云计算·aws
玩电脑的辣条哥2 小时前
Python如何播放本地音乐并在web页面播放
开发语言·前端·python
多想和从前一样5 小时前
Django 创建表时 “__str__ ”方法的使用
后端·python·django
小喵要摸鱼6 小时前
【Pytorch 库】自定义数据集相关的类
pytorch·python
bdawn6 小时前
深度集成DeepSeek大模型:WebSocket流式聊天实现
python·websocket·openai·api·实时聊天·deepseek大模型·流式输出
Jackson@ML6 小时前
Python数据可视化简介
开发语言·python·数据可视化
mosquito_lover16 小时前
怎么把pyqt界面做的像web一样漂亮
前端·python·pyqt
mengyoufengyu7 小时前
算法12-贪心算法
python·算法·贪心算法
网硕互联的小客服7 小时前
如何提高网站在百度中的权重?
linux·运维·服务器·windows·安全