如何修复 Python tox ImportError: cannot import name 'cmdline' from 'tox'
问题:
尝试使用 tox 运行单元测试时,你看到以下错误消息:
tox_traceback.txt
Traceback (most recent call last):
File "/home/uli/.local/bin/tox", line 5, in <module>
from tox import cmdline
ImportError: cannot import name 'cmdline' from 'tox' (/usr/local/lib/python3.10/dist-packages/tox/__init__.py)解决方案
你正在使用旧版本的 tox 作为可执行文件。要找出你正在使用哪个可执行文件,检查错误消息的这一行:
tox_exec_path.txt
File "/home/uli/.local/bin/tox", line 5, in <module>在我们的例子中,可执行文件是
tox_exec_path.txt
/home/uli/.local/bin/tox删除该文件!
之后,tox 应该正常工作。如果不正常,使用以下命令更新 tox
upgrade_tox.sh
pip install -U toxCheck out similar posts by category:
Python
If this post helped you, please consider buying me a coffee or donating via PayPal to support research & publishing of new posts on TechOverflow