ImportError: cannot import name ‘soft_unicode‘ from ‘markupsafe‘ (C:\Users\xxx\AppData\Local\Program

windows安装httprunner 3.1.6版本遇到报错(ImportError: cannot import name 'soft_unicode' from 'markupsafe' (C:\Users\wlm\AppData\Local\Programs\Python\Python39\lib\site-packages\markupsafe\__init__.py))

解决方案:pip install -U httprunner==3.1.11   #安装3.1.11版本

如有以下依赖库的报错,可参考进行升级版本,解决过程如下

步骤1:pip install httprunner==3.1.6

结果1:ImportError: cannot import name 'soft_unicode' from 'markupsafe' (C:\Users\xx\AppData\Local\Programs\Python\Python39\lib\site-packages\markupsafe\__init__.py)

注释:提示markupsafe库里少了soft_unicode,解决方法,更新markupsafe库

步骤2:pip install markupsafe==2.0.1 -i http://pypi.douban.com/simple/ --trusted-host pypi.douban.com       # pip install -U MarkupSafe==2.1.1(这条命令会timeout)

结果2: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.
werkzeug 2.2.1 requires MarkupSafe>=2.1.1, but you have markupsafe 2.0.1 which is incompatible.
flask 2.1.3 requires Jinja2>=3.0, but you have jinja2 2.11.3 which is incompatible.

注释:需要升级markupsafe 和jinja2 两个库的版本

步骤3.1:pip install -U markupsafe==2.1.1 -i http://pypi.douban.com/simple/ --trusted-host pypi.douban.com

步骤3.1:pip install -U jinja2==3.0

结果: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.
httprunner 3.1.6 requires jinja2<3.0.0,>=2.10.3, but you have jinja2 3.0.0 which is incompatible.

注释:升级完依赖库版本后,又绕回来了,追根究底是httprunner==3.1.6版本本身和我环境的问题,果断换版本。3.1.11是httprunner3系的最后一个版本.httpruner 官网地址

 

问题解决后:httprunner安装成功验证:httprunner -h,如下图即成功

 如下图即安装失败,hrrprunner 命令不可用,httprunner startproject demo不可用;

 

 

这个错误是由于在Python脚本中导入markupsafe库时出现了问题。具体来说,错误信息显示无法从markupsafe库中导入名为soft_unicode的属性。 解决这个问题的方法是降低markupsafe库的版本。你可以使用以下命令卸载当前版本的markupsafe库: pip uninstall markupsafe 然后,重新安装一个低版本的markupsafe库: pip install markupsafe==1.1.1 通过降低markupsafe库的版本,这个错误应该可以解决。如果你还遇到其他问题,可以参考Airtest官方网站中的教程或在他们的论坛上提问寻求帮助。 希望这个解决方案能够帮助你解决问题!如果还有其他疑问,请随时提问。<span class="em">1</span><span class="em">2</span><span class="em">3</span> #### 引用[.reference_title] - *1* [Jinja2安装报错解决方案- ImportError: cannot import name ‘soft_unicode‘ from ‘markupsafe](https://blog.csdn.net/HealerLX/article/details/123987865)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_1"}}] [.reference_item style="max-width: 33.333333333333336%"] - *2* [关于python3.9安装Airtest跑脚本“jinja2”报错的问题说明](https://blog.csdn.net/AirtestProject/article/details/124164837)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_1"}}] [.reference_item style="max-width: 33.333333333333336%"] - *3* [python3 解决cannot import name '_AES'问题](https://download.csdn.net/download/catheringwonder/10487632)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_1"}}] [.reference_item style="max-width: 33.333333333333336%"] [ .reference_list ]
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值