[问题记录]‘get_installed_distributions‘ cannot import

问题:Python运行报错get_installed_distributions cannot import

Traceback (most recent call last):
  File "/usr/lib/python3.6/runpy.py", line 193, in _run_module_as_main
    "__main__", mod_spec)
  File "/usr/lib/python3.6/runpy.py", line 85, in _run_code
    exec(code, run_globals)
  File "/usr/lib/python3/dist-packages/piptools/__main__.py", line 3, in 
    from piptools.scripts import compile, sync
  File "/usr/lib/python3/dist-packages/piptools/scripts/sync.py", line 10, in 
    from pip._internal.utils.misc import get_installed_distributions
ImportError: cannot import name 'get_installed_distributions'

定位解决:

  • 查询pip版本为pip 21.3.1
  • 原因:pip21.3没有get_installed_distributions方法
  • 解决方法:pip 降级/升级

pip3 install pip=21.2

你可能感兴趣的:(记录总结,python)