首页 > 其他分享 >1、ImportError: cannot import name 'soft_unicode' from 'markupsafe'解决;2、ImportErr

1、ImportError: cannot import name 'soft_unicode' from 'markupsafe'解决;2、ImportErr

时间:2023-12-02 17:11:24浏览次数:38  
标签:name anaconda3 ImportError py 18308 cannot import packages Users

不知做了啥操作,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

相关文章

  • 2023-12-02 cannot found module 'xxx'
    问题描述:运行命令报错找不到模块原因:你本地没装好依赖解决方案:删掉依赖,重新build但有时事实并不如此简单,就比如我记录这个bug,不仅仅是删掉依赖,重新build就可以了,还需要找到一个lock文件。如:yarn.lock,如果没有该文件,那么你拉下来的依赖的版本依旧不符合需求,原因就是版本号不同......
  • ORA-01187 cannot read from file 201 because it failed verification tests..temp01
    Description:WegetthismessageinrunningtheUpgradeExpress20-21export(create_customer_data):ORA-01187:cannotreadfromfile201becauseitfailedverificationtestsORA-01110:datafile201:'/exlibris/oradata/aleph20/aleph20_temp01.dbf'O......
  • DNS解析 CNAME!
    最近碰到一个需求,业务系统的访问域名是www.example.com,但是客户提需求能否通过example.com直接访问呢?讲实话我觉得这是没事找事,但要实现也是有办法的。这就涉及到DNS的CNAME记录了,我们都知道A记录时域名指向IPV4地址,那CNAME就是域名指向域名,我们新建一条CNAME记录@.example.com......
  • TypeError: Cannot read properties of undefined (reading '$modal')
    原代码:handleFinish(row){this.$modal.confirm('确认录取学生编号为"'+row.stuCode+'"的成绩?').then(function(){finishStudentScore({id:row.id}).then((response)=>{if(response.code==......
  • linux启动mysql数据库,报错mysql: error while loading shared libraries: libtinfo.so
    如下 原因: 解决方案:1、在/usr/lib64目录里面找一个差不多名称版本的文件进行链接#软连接出一个新的文件sudoln-s/usr/lib64/libtinfo.so.6.1/usr/lib64/libtinfo.so.5若本服务器没有相近版本的文件2、从其他服务器下载一个libtinfo.so.5拷贝进去即可,或者下载相近版本......
  • idea报错:XXX already exist in project. Please, specify another name.
    问题:idea报错:XXXalreadyexistinproject.Please,specifyanothername.并且左侧目录中并没有看见同名存在文件解决方法:1.打开File->ProjectStructure2.点击Modules->找到报错说存在的模块->点击减号删除->Apply->OK反思问题为什么存在应该是我在系统文件夹中之......
  • apache的文件名工具类FilenameUtils
    org.apache.commons.io.FilenameUtils。FileUtils和FilenameUtils分别是Apache对文件名和文件的封装,两者可以配合使用。<dependency><groupId>commons-io</groupId><artifactId>commons-io</artifactId><version>2.4</version></depe......
  • 解决非root用户安装软件中cannot create regular file `/usr/local/lib/libz.a‘: Per
    解决非root用户安装软件中cannotcreateregularfile`/usr/local/lib/libz.a':Permissiondenied举例解决办法 举例比如我现在要安装一个软件叫zlib,安装过程如下:wgethttp://zlib.net/zlib-1.2.11.tar.gztarzxfzlib-1.2.11.tar.gzcdzlib-1.2.11./configure......
  • array([['B1', 'B3', 'Unnamed: 2', 'B4', 'Unnamed: 4&#03
    array([['B1','B3','Unnamed:2','B4','Unnamed:4','Unnamed:5'],   ['B2',nan,'B5',nan,nan,nan],   [nan,nan,nan,nan,nan,'B6']],dtype=object)......
  • XXII Open Cup named after E.V. Pankratiev, Grand Prix of IMO
    Contestlink:XXIIOpenCupnamedafterE.V.Pankratiev,GrandPrixofIMO。M.Math题意:给你一个长度为\(n\)的数组\(a\),求有多少对\((i,j)\)满足\(a_i^2+a_j\)是完全平方数。\(1\len,a_i\le10^6\)。根据\(a\)统计出\(cnt\)数据,然后直接暴力枚举值即可。A.......