pytest运行警告问题解决:DeprecationWarning: pkg_resources is deprecated as an API
  iKXeBmqdRgYF 2023年11月02日 38 0

前言

最近在运行pytest的时候,经常出现这个警告DeprecationWarning: pkg_resources is deprecated as an API
See https://setuptools.pypa.io/en/latest/pkg_resources.html from pkg_resources import iter_entry_points
从警告上看是方法被弃用,肯定是因为新版弃用了旧版的语法。

遇到问题

执行pytest用例出现警告

D:\pycharm\PyCharm 2020.1.5\plugins\python\helpers\pycharm\_jb_pytest_runner.py:7: DeprecationWarning: pkg_resources is deprecated as an API. See https://setuptools.pypa.io/en/latest/pkg_resources.html
  from pkg_resources import iter_entry_points

pytest运行警告问题解决:DeprecationWarning: pkg_resources is deprecated as an API_pytest

之前一直因为是pytest版本太高了,后来发现不是。仔细对比之前的项目,发现是setuptools 版本升级导致的。

解决问题

出现问题的setuptools 版本:68.2.0

(venv) D:\a_demo\web_pom_play>pip show setuptools
Name: setuptools
Version: 68.2.0

先卸载setuptools

pip uninstall setuptools

安装67.6.1版本

pip install setuptools==67.6.1

到此问题解决



【版权声明】本文内容来自摩杜云社区用户原创、第三方投稿、转载,内容版权归原作者所有。本网站的目的在于传递更多信息,不拥有版权,亦不承担相应法律责任。如果您发现本社区中有涉嫌抄袭的内容,欢迎发送邮件进行举报,并提供相关证据,一经查实,本社区将立刻删除涉嫌侵权内容,举报邮箱: cloudbbs@moduyun.com

  1. 分享:
最后一次编辑于 2023年11月08日 0

暂无评论

推荐阅读
  2Fnpj8K6xSCR   2024年05月17日   100   0   0 Python
  xKQN3Agd2ZMK   2024年05月17日   70   0   0 Python
  Ugrw6b9GgRUv   2024年05月17日   40   0   0 Python
  YpHJ7ITmccOD   2024年05月17日   39   0   0 Python
iKXeBmqdRgYF