方法一(失败)、按照网络教程将Jupyter Notebook属性 目标中的 %USERPROFILE%替换为目标路径D:\CodeTest
打开Jupyter Notebook失败,报错如下:
(base) C:\Users\Administrator>jupyter notebook
[C 2025-03-21 16:42:49.664 ServerApp] Bad config encountered during initialization: The ‘kernel_spec_manager_class’ trait of <jupyter_server.serverapp.ServerApp object at 0x0000026AD37D3A70> instance must be a type, but ‘nb_conda_kernels.CondaKernelSpecManager’ could not be imported
原因是 缺少 nb_conda_kernels 模块
解决方案 安装 nb_conda_kernels
在 Conda 环境中安装包
打开 Anaconda Prompt,运行:
conda install -n base nb_conda_kernels -c conda-forge
验证安装
conda list -n base | findstr "nb_conda_kernels"
# 应输出类似:nb_conda_kernels 3.0.0 pyhd8ed1ab_0 conda-forge
重新启动 Jupyter Notebook成功,但是还是默认路径
方法二、使用cd命令切换路径至D:\CodeTest
cd /d D:\CodeTest
jupyter notebook
#Ctrl+C退出
工作目录更改成功~