gpt4 book ai didi

python - Pytest E DeprecationWarning : defusedxml. lxml 不再受支持,将在未来版本中删除

转载 作者:行者123 更新时间:2023-12-04 16:45:17 27 4
gpt4 key购买 nike

我有一个简单的python代码,如下所示:

文件名:test_pytest_openpyxl.py

import openpyxl

def test_1():
print("test_1")

if __name__ == "__main__":
test_1()

python test_pytest_openpyxl.py

它通过了没有错误。然而,

pytest test_pytest_openpyxl.py 给出了以下错误:
================================================= test session starts ==================================================
platform linux -- Python 3.7.4, pytest-5.3.3, py-1.8.0, pluggy-0.13.1
plugins: arraydiff-0.3, astropy-header-0.1.1, doctestplus-0.5.0, openfiles-0.4.0, remotedata-0.3.2
collected 0 items / 1 error

======================================================== ERRORS ========================================================
_________________________________________ ERROR collecting test_pytest_xml.py __________________________________________
/home/user/anaconda3/lib/python3.7/site-packages/py/_path/local.py:701: in pyimport
__import__(modname)
<frozen importlib._bootstrap>:983: in _find_and_load
???
<frozen importlib._bootstrap>:967: in _find_and_load_unlocked
???
<frozen importlib._bootstrap>:677: in _load_unlocked
???
/home/user/anaconda3/lib/python3.7/site-packages/_pytest/assertion/rewrite.py:143: in exec_module
exec(co, module.__dict__)
C:\Users\v-jonluo\repo\performance\perf_lib\py_lib\gantt_model\pytest\test_pytest_xml.py:1: in <module>
???
/home/user/anaconda3/lib/python3.7/site-packages/openpyxl/__init__.py:6: in <module>
from openpyxl.workbook import Workbook
/home/user/anaconda3/lib/python3.7/site-packages/openpyxl/workbook/__init__.py:5: in <module>
from .workbook import Workbook
/home/user/anaconda3/lib/python3.7/site-packages/openpyxl/workbook/workbook.py:8: in <module>
from openpyxl.worksheet.worksheet import Worksheet
/home/user/anaconda3/lib/python3.7/site-packages/openpyxl/worksheet/worksheet.py:30: in <module>
from openpyxl.cell import Cell, MergedCell
/home/user/anaconda3/lib/python3.7/site-packages/openpyxl/cell/__init__.py:4: in <module>
from .cell import Cell, WriteOnlyCell, MergedCell
/home/user/anaconda3/lib/python3.7/site-packages/openpyxl/cell/cell.py:46: in <module>
from openpyxl.utils.inference import (
/home/user/anaconda3/lib/python3.7/site-packages/openpyxl/utils/inference.py:10: in <module>
from openpyxl.styles import numbers
/home/user/anaconda3/lib/python3.7/site-packages/openpyxl/styles/__init__.py:5: in <module>
from .alignment import Alignment
/home/user/anaconda3/lib/python3.7/site-packages/openpyxl/styles/alignment.py:6: in <module>
from openpyxl.descriptors import Bool, MinMax, Min, Alias, NoneSet
/home/user/anaconda3/lib/python3.7/site-packages/openpyxl/descriptors/__init__.py:5: in <module>
from .sequence import Sequence
/home/user/anaconda3/lib/python3.7/site-packages/openpyxl/descriptors/sequence.py:5: in <module>
from openpyxl.xml.functions import Element
/home/user/anaconda3/lib/python3.7/site-packages/openpyxl/xml/functions.py:31: in <module>
from defusedxml.lxml import fromstring as _fromstring, tostring
/home/user/anaconda3/lib/python3.7/site-packages/defusedxml/lxml.py:29: in <module>
stacklevel=2,
E DeprecationWarning: defusedxml.lxml is no longer supported and will be removed in a future release.
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! Interrupted: 1 error during collection !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
=================================================== 1 error in 4.19s ===================================================

环境:
Ubuntu 18.04/Windows 10、Pythion 3.7.4、openpyxl 2.6.2、pytest-5.3.3、setuptools 45.1.0

最佳答案

此警告 has been fixed recently
您应该尝试使用更新版本的 lib 来摆脱它( 3.0.3 is available )

关于python - Pytest E DeprecationWarning : defusedxml. lxml 不再受支持,将在未来版本中删除,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60749381/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com