You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

命令行运行Python-Selenium脚本遇Allure导入错误求助

解决allure-pytest与allure-commons版本不兼容导致的导入错误

问题分析

你遇到的ImportError: cannot import name 'escape_non_unicode_symbols' from 'allure_commons.utils'是由于allure-pytest和allure-commons两个包版本不匹配造成的——当前安装的allure-pytest版本依赖escape_non_unicode_symbols函数,但你安装的allure-commons版本中没有这个函数(或已被移除/重命名)。

解决步骤

1. 卸载现有冲突包

先彻底卸载当前的allure相关包:

pip uninstall -y allure-pytest allure-commons

2. 安装兼容版本组合

选择以下任一方式安装匹配的版本:

  • 指定稳定兼容版本(推荐,避免版本冲突):
pip install allure-pytest==2.12.0 allure-commons==2.12.0
  • 升级到最新兼容版本:
pip install --upgrade allure-pytest allure-commons

3. 验证安装

执行以下命令确认版本匹配:

pip show allure-pytest allure-commons

确保两个包的版本号一致。

额外注意

如果使用了虚拟环境,务必切换到对应的虚拟环境中执行上述命令,避免全局Python包与虚拟环境包冲突。

内容的提问来源于stack exchange,提问作者Satish Ghanta

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.28 19:54:54