【问题标题】:Pandas Profiling Import Error: cannot import name 'soft_unicode' from 'markupsafe'Pandas 分析导入错误:无法从 \'markupsafe\' 导入名称 \'soft_unicode\'
【发布时间】:2022-08-14 01:19:09
【问题描述】:
我在开始使用 pandas 分析时遇到问题。
我尝试加载 pandas 分析,但安装时会弹出此错误:
错误:pip\ 的依赖解析器当前不考虑所有已安装的包。此行为是以下依赖冲突的根源。
anaconda-project 0.9.1 需要未安装的 ruamel-yaml。
sphinx 4.0.1 需要 MarkupSafe<2.0,但您有不兼容的 markupsafe 2.1.1。
我试图通过安装早期版本来修复它。
但是,如果我按照指示安装低于 2.0 的 MarkupSafe 版本,则会收到以下错误:
pandas-profiling 3.2.0 需要 markupsafe~=2.1.1,但是你有不兼容的 markupsafe 2.0.1
现在,如果我只是尝试使用 pandas 分析,我会收到错误消息:
无法从 \'markupsafe\' 导入名称 \'soft_unicode\'
这是我使用的代码:
from pandas_profiling import ProfileReport
import pandas as pd
df = pd.read_excel(\"WBNAME\", sheetname = None)
prof = ProfileReport(df)
prof.to_file(output_file=\'output.html\')
我究竟应该在这里做什么才能使用熊猫分析?
标签:
python
pandas
profiling
【解决方案1】:
试试下面几行,也许它有效
import pandas_profiling as pp
df = pd.read_excel("WBNAME", sheetname = None)
profile= pp.ProfileReport(df)
profile.to_file('pandas_profile_test.html')
【解决方案3】:
这是一个不幸的情况,当您的包代码被其他软件用作依赖项时,事情就会崩溃,并且您无法预见/测试所有用例。
这对我有用:
!pip uninstall markupsafe
!pip install markupsafe==2.0.1
然后,如果使用笔记本,重启并导入pandas-profiling。
基本原理:重新安装仍支持 soft_unicode 的先前版本的 markupsafe 将引发此错误:
ERROR: pip's dependency resolver does not currently take into account all the packages that are installed. This behaviour is the source of the following dependency conflicts.
pandas-profiling 3.2.0 requires markupsafe~=2.1.1, but you have markupsafe 2.0.1 which is incompatible.
但是,后面的行仍然说:
Successfully installed markupsafe-2.0.1
所以,good2go。