Skip to content

ImportError: cannot import name 'LegacyVersion' from 'packaging.version' #3171

Description

@soimkim

Description

Please leave a brief description of the bug or feature request:

  • packaging 22.0 released.
  • As a result, the following error occurs when importing ScanCode.
========================================================================
ERROR: UNABLE TO IMPORT SCANCODE PLUGINS.
Check your installation configuration (setup.py) or re-install/re-configure ScanCode.
The following plugin(s) are referenced and cannot be loaded/imported:
cannot import name 'LegacyVersion' from 'packaging.version' (/home/worker/git/fosslight_source_scanner/.tox/release/lib/python3.8/site-packages/packaging/version.py)
========================================================================
File "/home/worker/git/fosslight_source_scanner/.tox/release/lib/python3.8/site-packages/fosslight_source/run_scancode.py", line 11, in <module>
    from scancode import cli
  File "/home/worker/git/fosslight_source_scanner/.tox/release/lib/python3.8/site-packages/scancode/cli.py", line 126, in <module>
    raise e
  File "/home/worker/git/fosslight_source_scanner/.tox/release/lib/python3.8/site-packages/scancode/cli.py", line 113, in <module>
    plugin_classes, plugin_options = PluginManager.load_plugins()
  File "/home/worker/git/fosslight_source_scanner/.tox/release/lib/python3.8/site-packages/plugincode/__init__.py", line 196, in load_plugins
    mgr_setup = manager.setup()
  File "/home/worker/git/fosslight_source_scanner/.tox/release/lib/python3.8/site-packages/plugincode/__init__.py", line 222, in setup
    raise e
  File "/home/worker/git/fosslight_source_scanner/.tox/release/lib/python3.8/site-packages/plugincode/__init__.py", line 220, in setup
    self.manager.load_setuptools_entrypoints(entrypoint)
  File "/home/worker/git/fosslight_source_scanner/.tox/release/lib/python3.8/site-packages/pluggy/_manager.py", line 287, in load_setuptools_entrypoints
    plugin = ep.load()
  File "/usr/lib/python3.8/importlib/metadata.py", line 77, in load
    module = import_module(match.group('module'))
  File "/usr/lib/python3.8/importlib/__init__.py", line 127, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "/home/worker/git/fosslight_source_scanner/.tox/release/lib/python3.8/site-packages/packagedcode/__init__.py", line 23, in <module>
    from packagedcode import conda
  File "/home/worker/git/fosslight_source_scanner/.tox/release/lib/python3.8/site-packages/packagedcode/conda.py", line 16, in <module>
    from packagedcode.pypi import BaseDependencyFileHandler
  File "/home/worker/git/fosslight_source_scanner/.tox/release/lib/python3.8/site-packages/packagedcode/pypi.py", line 28, in <module>
    import pip_requirements_parser
  File "/home/worker/git/fosslight_source_scanner/.tox/release/lib/python3.8/site-packages/pip_requirements_parser.py", line 73, in <module>
    from packaging.version import LegacyVersion
ImportError: cannot import name 'LegacyVersion' from 'packaging.version' (/home/worker/git/fosslight_source_scanner/.tox/release/lib/python3.8/site-packages/packaging/version.py)
release: exit 1 (0.80 seconds) /home/worker/git/fosslight_source_scanner> fosslight_source -h pid=1095
.pkg: _exit> python /home/worker/venv38/lib/python3.8/site-packages/pyproject_api/_backend.py True setuptools.build_meta __legacy__
  release: FAIL code 1 (2.30=setup[1.50]+cmd[0.80] seconds)
  evaluation failed :( (2.35 seconds)
 

How To Reproduce

Tell us how to reproduce the issue.

  • Install ScanCode with packaging version 22.0 (latest version).

System configuration

For bug reports, it really helps us to know:

  • What OS are you running on? Ubuntu
  • What version of scancode-toolkit was used to generate the scan file? 31.2.1
  • What installation method was used to install/run scancode? pip

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions