TOC

Pipenv:PkgResourcesDeprecationWarning

~/.local/lib/python3.10/site-packages/pkg_resources/__init__.py:123: PkgResourcesDeprecationWarning: 1.1build1 is an invalid version and will not be supported in a future release
  warnings.warn(
~/.local/lib/python3.10/site-packages/pkg_resources/__init__.py:123: PkgResourcesDeprecationWarning: 0.1.43ubuntu1 is an invalid version and will not be supported in a future release
  warnings.warn(
~/.local/lib/python3.10/site-packages/pkg_resources/__init__.py:123: PkgResourcesDeprecationWarning: 2.9.0.Odd.Olm is an invalid version and will not be supported in a future release
  warnings.warn(

Pipenv 最近执行命令的时候会有这些提示,看这个意思是检测了一些 Python 包的版本不被支持。
用 traceback 排查之后,确认是在 Python PATH 下检查所有包的版本。
出问题的三个包是:

  • distro-info <LegacyVersion('1.1build1')> /usr/lib/python3/dist-packages
  • python-debian <LegacyVersion('0.1.43ubuntu1')> /usr/lib/python3/dist-packages
  • Shredder <LegacyVersion('2.9.0.Odd.Olm')> /usr/lib/python3/dist-packages

查找路径:

~/.local/lib/python3.10/site-packages/pipenv/patched
~/.local/lib/python3.10/site-packages/pipenv/vendor
~/Projects/Mine/staticize
/usr/lib/python310.zip
/usr/lib/python3.10
/usr/lib/python3.10/lib-dynload
~/.local/lib/python3.10/site-packages
~/.local/lib/python3.10/site-packages/mackup-0.8.33-py3.10.egg
/usr/local/lib/python3.10/dist-packages
/usr/lib/python3/dist-packages

相关代码:

File "~/.local/lib/python3.10/site-packages/pkg_resources/__init__.py", line 997, in __init__
  self.scan(search_path)
File "~/.local/lib/python3.10/site-packages/pkg_resources/__init__.py", line 1030, in scan
  self.add(dist)
File "~/.local/lib/python3.10/site-packages/pkg_resources/__init__.py", line 1050, in add
  dists.sort(key=operator.attrgetter('hashcmp'), reverse=True)
File "~/.local/lib/python3.10/site-packages/pkg_resources/__init__.py", line 2623, in hashcmp
  self.parsed_version,
File "~/.local/lib/python3.10/site-packages/pkg_resources/__init__.py", line 2671, in parsed_version
  self._parsed_version = parse_version(self.version)
File "~/.local/lib/python3.10/site-packages/pkg_resources/__init__.py", line 122, in parse_version
  print(''.join(traceback.format_stack()))