不知做了啥操作,spyder和jupyter同时打不开(我印象中啥也没做),出现闪了一下后没反应,不知道报错在哪里。
1、先解决spyder的报错:ImportError: cannot import name 'soft_unicode' from 'markupsafe'
于是我打开Anaconda,找到Spyder点击launch,
报错如下:
Traceback (most recent call last):
File "C:\Users\18308\anaconda3\Scripts\spyder-script.py", line 10, in
sys.exit(main())
File "C:\Users\18308\anaconda3\lib\site-packages\spyder\app\start.py", line 201, in main
from spyder.app import mainwindow
File "C:\Users\18308\anaconda3\lib\site-packages\spyder\app\mainwindow.py", line 178, in
from spyder.plugins.help.utils.sphinxify import CSS_PATH, DARK_CSS_PATH
File "C:\Users\18308\anaconda3\lib\site-packages\spyder\plugins\help\utils\sphinxify.py", line 34, in
from jinja2 import Environment, FileSystemLoader
File "C:\Users\18308\anaconda3\lib\site-packages\jinja2\__init__.py", line 12, in
from .environment import Environment
File "C:\Users\18308\anaconda3\lib\site-packages\jinja2\environment.py", line 25, in
from .defaults import BLOCK_END_STRING
File "C:\Users\18308\anaconda3\lib\site-packages\jinja2\defaults.py", line 3, in
from .filters import FILTERS as DEFAULT_FILTERS # noqa: F401
File "C:\Users\18308\anaconda3\lib\site-packages\jinja2\filters.py", line 13, in
from markupsafe import soft_unicode
ImportError: cannot import name 'soft_unicode' from 'markupsafe'
(C:\Users\18308\anaconda3\lib\site-packages\markupsafe\__init__.py)
百度了一下怎么处理,解决方法如下:参考文章https://www.cnblogs.com/Fiona770315/p/16697895.html
打开anaconda命令行:
查看这个库是否存在: pip show markupsafe
查看,已经安装,则重新安装一下
若存在重新安装 python -m pip install markupsafe==2.0.1 #我也不知道为什么要重新装这个版本的,有大佬知道可以解释一下?
再次启动Spyder就可以打开了
不知道为什么jupyter仍然还是闪退的情况?
2、解决jupyter的报错:ImportError: cannot import name 'Callable' from 'traitlets'
同样的操作,打开Anaconda,找到Spyder点击launch,报错如下:
Traceback (most recent call last):
File "C:\Users\18308\anaconda3\lib\site-packages\jupyterlab_server\server.py", line 20, in
from notebook.notebookapp import aliases, flags, NotebookApp as ServerApp
File "C:\Users\18308\anaconda3\lib\site-packages\notebook\notebookapp.py", line 80, in
from .services.contents.manager import ContentsManager
File "C:\Users\18308\anaconda3\lib\site-packages\notebook\services\contents\manager.py", line 17, in
from nbformat import sign, validate as validate_nb, ValidationError
File "C:\Users\18308\anaconda3\lib\site-packages\nbformat\sign.py", line 39, in
from traitlets import Any, Bool, Bytes, Callable, Enum, Instance, Integer, Unicode, default, observe
ImportError: cannot import name 'Callable' from 'traitlets'
(C:\Users\18308\anaconda3\lib\site-packages\traitlets\__init__.py)
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "C:\Users\18308\anaconda3\Scripts\jupyter-lab-script.py", line 5, in
from jupyterlab.labapp import main
File "C:\Users\18308\anaconda3\lib\site-packages\jupyterlab\labapp.py", line 14, in
from jupyterlab_server import slugify, WORKSPACE_EXTENSION
File "C:\Users\18308\anaconda3\lib\site-packages\jupyterlab_server\__init__.py", line 4, in
from .app import LabServerApp
File "C:\Users\18308\anaconda3\lib\site-packages\jupyterlab_server\app.py", line 9, in
from .server import ServerApp
File "C:\Users\18308\anaconda3\lib\site-packages\jupyterlab_server\server.py", line 26, in
from jupyter_server.base.handlers import ( # noqa
ModuleNotFoundError: No module named 'jupyter_server'
百度了一下怎么处理,解决方法如下:参考文章https://blog.csdn.net/Junehhh/article/details/129196356
说是导入traitlets的内容报错,可以重新安装traitlets这个包
anaconda命令行运行:python -m pip install traitlets -U --force-reinstall
再次启动jupyter发现成功打开了
但是有个问题,不知道上面那行红色的报错对之后有没有影响ERROR: nbconvert 5.6.1 has requirement mistune<2,>=0.8.1, but you'll have mistune 3.0.2 which is incompatible. 反正暂时可以正常使用了
标签:name,anaconda3,ImportError,py,18308,cannot,import,packages,Users From: https://www.cnblogs.com/lizixi/p/17871829.html