Jupyter Notebook无法打开报expected string or bytes-like object错误求助
解决Anaconda Base环境Jupyter Notebook启动报错“expected string or bytes-like object”
问题背景
为在Jupyter Notebook中安装TensorFlow,创建虚拟环境后,虚拟环境的Jupyter可正常打开,但原常用的Anaconda Base环境Jupyter Notebook无法启动,报错“expected string or bytes-like object”,删除虚拟环境后问题仍存在。
修复方案
1. 重置Jupyter配置文件
配置文件损坏是常见诱因,执行以下命令强制重新生成配置文件:
jupyter notebook --generate-config --force
2. 重装Base环境的Jupyter相关依赖
虚拟环境操作可能导致base环境的Jupyter包版本冲突,彻底重装相关组件:
conda activate base conda remove --force jupyter jupyter_core jupyter_client ipython ipykernel conda install jupyter ipython ipykernel
3. 清理残留环境变量(可选)
检查系统PATH环境变量,若存在已删除虚拟环境的路径,将其移除后重启终端,再尝试启动Jupyter。
4. 验证修复
执行jupyter notebook命令,确认Base环境的Jupyter Notebook是否能正常启动。
内容的提问来源于stack exchange,提问作者Valent Aderiandra
相关产品推荐
相关产品推荐

