MacBook pip安装JupyterLab后启动报错:应用资产未找到
解决JupyterLab运行时找不到应用资源的问题
问题场景
在MacBook上通过pip安装JupyterLab后,执行jupyter lab启动时浏览器弹出错误:
JupyterLab Error JupyterLab application assets not found in
"/opt/homebrew/Cellar/python@3.10/3.10.6_2/Frameworks/Python.framework/Versions/3.10/share/jupyter/lab"
Please runjupyter lab buildor use a different app directory
同时Jupyter Notebook可正常运行,使用jupyter lab --code-mode也能正常启动JupyterLab。
解决方案
1. 执行资源构建命令
直接运行终端命令重新构建JupyterLab前端资源:
jupyter lab build
若出现权限报错,可尝试添加sudo前缀执行(优先建议检查pip安装时的权限设置,避免过度使用sudo)。
2. 指定自定义应用目录
若构建命令无效,可手动指定用户目录作为JupyterLab的资源存储路径:
- 创建本地资源目录:
mkdir -p ~/.jupyter/lab
- 启动时指定该目录:
jupyter lab --app-dir=~/.jupyter/lab
- 永久配置:生成并修改JupyterLab配置文件,避免每次手动指定:
- 生成配置文件(首次执行):
jupyter lab --generate-config- 打开
~/.jupyter/jupyter_lab_config.py,找到c.LabApp.app_dir项,取消注释并设置为自定义路径:
c.LabApp.app_dir = '~/.jupyter/lab'
3. 彻底重装JupyterLab
如果上述方法均无效,尝试彻底卸载后重新安装:
- 卸载JupyterLab:
pip uninstall jupyterlab -y
- 删除残留的资源和配置文件:
rm -rf ~/.jupyter/lab rm -rf /opt/homebrew/Cellar/python@3.10/3.10.6_2/Frameworks/Python.framework/Versions/3.10/share/jupyter/lab
- 重新安装:
pip install jupyterlab
内容的提问来源于stack exchange,提问作者Yusuf UYANIK
相关产品推荐
相关产品推荐

