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

PyCharm运行/调试Tox报错:找不到packaging模块,终端运行正常

PyCharm与Tox兼容问题排查

问题现象

  • 在PyCharm终端执行tox命令时,所有测试可正常启动
  • 使用PyCharm运行/调试按钮(Ctrl+Shift+R)执行测试时,抛出模块找不到错误

错误信息

from packaging.requirements import InvalidRequirement, Requirement
ModuleNotFoundError: No module named 'packaging'

Process finished with exit code 1

Empty suite

当前环境状态

  • PyCharm已将默认Python设为项目解释器
  • 本地Python环境中packaging模块已安装:
bart automated-tests % pip install packaging     
Requirement already satisfied: packaging in /Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages (24.1)

tox.ini配置内容

[tox]
envlist = tests
skipsdist = True

[testenv]
basepython = python3
commands =
   pytest {posargs}


[pytest]

addopts =
    --basetemp="{envtmpdir}"
    --confcutdir=..
    --sensitive-url=NONE
    --driver Chrome
    --capability browserName chrome
    --alluredir=reports
    --base-url="https://proper_url"

疑问

已查阅相关资料未找到解决方案,为何PyCharm运行/调试按钮无法正常执行测试?

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.06.20 19:37:01