Debug 模式执行Python代码报错信息如下,
报错信息:TypeError: BaseXmlEnum.__new__() missing 2 required positional arguments: 'xml_value' and 'docstr' Error calling __set_name__ on '_proto_member' instance 'automatic' in 'WD_COLOR_INDEX'
错误信息截图如下:
解决思路:
发现没有进入到代码方法断点位置,因此判断是包版本或者包冲突问题。最终在AI的帮助下步骤2完成后解决上述问题。
请ChatGPT帮忙debug如下:
The error you're encountering seems to be related to a conflict or incompatibility in the enum module used by the docx package. To debug and resolve this issue, try the following steps:
- Check the enum34 package: Ensure that you are not using the enum34 backport package, which is meant for Python versions prior to 3.4. This can cause conflicts in Python 3.6 and later.
- Update the python-docx package: Ensure that you are using the latest version of python-docx. You can update it using pip:bashCopy codepip install --upgrade python-docx
- Check for Conflicting Packages: Sometimes, different packages can introduce conflicts. Ensure that no other packages in your environment are causing this issue.
- Check Python Version: Ensure you are using a compatible version of Python. python-docx works well with Python 3.6 and later.