ImportError: cannot import name 'Sequence' from 'collections' with Python > 3.9

Bug #2031617 reported by Aleksander Korzyński
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
git-upstream
In Progress
Undecided
Aleksander Korzyński

Bug Description

Error while attempting to install git-upstream with Python > 3.9:

$ python3.11 -m pip install .
DEPRECATION: Loading egg at /usr/local/Cellar/gpgme/1.21.0/lib/python3.11/site-packages/gpg-1.21.0-py3.11-macosx-12-x86_64.egg is deprecated. pip 23.3 will enforce this behaviour change. A possible replacement is to use pip for package installation..
Processing /mydir/git-upstream
  Preparing metadata (setup.py) ... error
  error: subprocess-exited-with-error

  × python setup.py egg_info did not run successfully.
  │ exit code: 1
  ╰─> [94 lines of output]
      /usr/local/lib/python3.11/site-packages/setuptools/dist.py:788: UserWarning: Usage of dash-separated 'author-email' will not be supported in future versions. Please use the underscore name 'author_email' instead
        warnings.warn(
      /usr/local/lib/python3.11/site-packages/setuptools/dist.py:788: UserWarning: Usage of dash-separated 'home-page' will not be supported in future versions. Please use the underscore name 'home_page' instead
        warnings.warn(
      /usr/local/lib/python3.11/site-packages/setuptools/dist.py:788: UserWarning: Usage of dash-separated 'description-file' will not be supported in future versions. Please use the underscore name 'description_file' instead
        warnings.warn(
      /usr/local/lib/python3.11/site-packages/setuptools/__init__.py:85: _DeprecatedInstaller: setuptools.installer and fetch_build_eggs are deprecated. Requirements should be satisfied by a PEP 517 installer. If you are using pip, you can try `pip install --use-pep517`.
        dist.fetch_build_eggs(dist.setup_requires)
      [pbr] Generating ChangeLog
      /usr/local/lib/python3.11/site-packages/setuptools/command/easy_install.py:144: EasyInstallDeprecationWarning: easy_install command is deprecated. Use build and pip and other standards-based tools.
        warnings.warn(
      /usr/local/lib/python3.11/site-packages/setuptools/command/install.py:34: SetuptoolsDeprecationWarning: setup.py install is deprecated. Use build and pip and other standards-based tools.
        warnings.warn(
      /usr/local/lib/python3.11/site-packages/setuptools/dist.py:788: UserWarning: Usage of dash-separated 'author-email' will not be supported in future versions. Please use the underscore name 'author_email' instead
        warnings.warn(
      /usr/local/lib/python3.11/site-packages/setuptools/dist.py:788: UserWarning: Usage of dash-separated 'home-page' will not be supported in future versions. Please use the underscore name 'home_page' instead
        warnings.warn(
      /usr/local/lib/python3.11/site-packages/setuptools/dist.py:788: UserWarning: Usage of dash-separated 'description-file' will not be supported in future versions. Please use the underscore name 'description_file' instead
        warnings.warn(
      running egg_info
      creating /private/var/folders/s7/n126d3fs0ygcp_vwc4jc4f2w0000gn/T/pip-pip-egg-info-ppimwqto/git_upstream.egg-info
      writing pbr to /private/var/folders/s7/n126d3fs0ygcp_vwc4jc4f2w0000gn/T/pip-pip-egg-info-ppimwqto/git_upstream.egg-info/pbr.json
      writing /private/var/folders/s7/n126d3fs0ygcp_vwc4jc4f2w0000gn/T/pip-pip-egg-info-ppimwqto/git_upstream.egg-info/PKG-INFO
      writing dependency_links to /private/var/folders/s7/n126d3fs0ygcp_vwc4jc4f2w0000gn/T/pip-pip-egg-info-ppimwqto/git_upstream.egg-info/dependency_links.txt
      writing entry points to /private/var/folders/s7/n126d3fs0ygcp_vwc4jc4f2w0000gn/T/pip-pip-egg-info-ppimwqto/git_upstream.egg-info/entry_points.txt
      writing requirements to /private/var/folders/s7/n126d3fs0ygcp_vwc4jc4f2w0000gn/T/pip-pip-egg-info-ppimwqto/git_upstream.egg-info/requires.txt
      writing top-level names to /private/var/folders/s7/n126d3fs0ygcp_vwc4jc4f2w0000gn/T/pip-pip-egg-info-ppimwqto/git_upstream.egg-info/top_level.txt
      [pbr] Processing SOURCES.txt
      writing manifest file '/private/var/folders/s7/n126d3fs0ygcp_vwc4jc4f2w0000gn/T/pip-pip-egg-info-ppimwqto/git_upstream.egg-info/SOURCES.txt'
      /usr/local/lib/python3.11/site-packages/setuptools/command/build.py:31: SetuptoolsDeprecationWarning:
                  It seems that you are using `distutils.command.build` to add
                  new subcommands. Using `distutils` directly is considered deprecated,
                  please use `setuptools.command.build`.

        warnings.warn(msg, SetuptoolsDeprecationWarning)
      Traceback (most recent call last):
        File "<string>", line 2, in <module>
        File "<pip-setuptools-caller>", line 34, in <module>
        File "/mydir/git-upstream/setup.py", line 25, in <module>
          setuptools.setup(
        File "/usr/local/lib/python3.11/site-packages/setuptools/__init__.py", line 108, in setup
          return distutils.core.setup(**attrs)
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
        File "/usr/local/lib/python3.11/site-packages/setuptools/_distutils/core.py", line 185, in setup
          return run_commands(dist)
                 ^^^^^^^^^^^^^^^^^^
        File "/usr/local/lib/python3.11/site-packages/setuptools/_distutils/core.py", line 201, in run_commands
          dist.run_commands()
        File "/usr/local/lib/python3.11/site-packages/setuptools/_distutils/dist.py", line 969, in run_commands
          self.run_command(cmd)
        File "/usr/local/lib/python3.11/site-packages/setuptools/dist.py", line 1221, in run_command
          super().run_command(command)
        File "/usr/local/lib/python3.11/site-packages/setuptools/_distutils/dist.py", line 988, in run_command
          cmd_obj.run()
        File "/usr/local/lib/python3.11/site-packages/setuptools/command/egg_info.py", line 318, in run
          self.find_sources()
        File "/usr/local/lib/python3.11/site-packages/pbr/packaging.py", line 579, in find_sources
          mm.run()
        File "/usr/local/lib/python3.11/site-packages/setuptools/command/egg_info.py", line 570, in run
          self.add_defaults()
        File "/usr/local/lib/python3.11/site-packages/pbr/packaging.py", line 541, in add_defaults
          sdist.sdist.add_defaults(self)
        File "/usr/local/lib/python3.11/site-packages/setuptools/command/sdist.py", line 107, in add_defaults
          self._add_defaults_build_sub_commands()
        File "/usr/local/lib/python3.11/site-packages/setuptools/command/sdist.py", line 127, in _add_defaults_build_sub_commands
          self.filelist.extend(chain.from_iterable(files))
        File "/usr/local/lib/python3.11/site-packages/setuptools/command/egg_info.py", line 513, in extend
          self.files.extend(filter(self._safe_path, paths))
        File "/usr/local/lib/python3.11/site-packages/setuptools/command/sdist.py", line 126, in <genexpr>
          files = (c.get_source_files() for c in cmds if hasattr(c, "get_source_files"))
                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
        File "/usr/local/lib/python3.11/site-packages/setuptools/command/sdist.py", line 125, in <genexpr>
          cmds = (self.get_finalized_command(c) for c in missing_cmds)
                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
        File "/usr/local/lib/python3.11/site-packages/setuptools/_distutils/cmd.py", line 305, in get_finalized_command
          cmd_obj.ensure_finalized()
        File "/usr/local/lib/python3.11/site-packages/setuptools/_distutils/cmd.py", line 111, in ensure_finalized
          self.finalize_options()
        File "/mydir/git-upstream/doc/utils/build_manpage.py", line 45, in finalize_options
          self._commands, self._parser = main.build_parsers()
                                         ^^^^^^^^^^^^^^^^^^^^
        File "/mydir/git-upstream/git_upstream/main.py", line 67, in build_parsers
          subcommand_parsers = commands.get_subcommands(parser)
                               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
        File "/mydir/git-upstream/git_upstream/commands/__init__.py", line 79, in get_subcommands
          subcommands = _find_actions(subparsers, os.path.dirname(__file__))
                        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
        File "/mydir/git-upstream/git_upstream/commands/__init__.py", line 91, in _find_actions
          __import__(__name__ + '.' + mod)
        File "/mydir/git-upstream/git_upstream/commands/import.py", line 21, in <module>
          from git_upstream.lib.strategies import ImportStrategiesFactory
        File "/mydir/git-upstream/git_upstream/lib/strategies.py", line 21, in <module>
          from collections import Sequence
      ImportError: cannot import name 'Sequence' from 'collections' (/usr/local/Cellar/python@3.11/3.11.4_1/Frameworks/Python.framework/Versions/3.11/lib/python3.11/collections/__init__.py)
      [end of output]

  note: This error originates from a subprocess, and is likely not a problem with pip.
error: metadata-generation-failed

× Encountered error while generating package metadata.
╰─> See above for output.

note: This is an issue with the package mentioned above, not pip.
hint: See above for details.

Revision history for this message
Aleksander Korzyński (akorzy) wrote :

This issue can be fixed by changing:

-from collections import Sequence
+from collections.abc import Sequence

summary: - ImportError: cannot import name 'Sequence' from 'collections' on Python
- > 3.9
+ ImportError: cannot import name 'Sequence' from 'collections' with
+ Python > 3.9
description: updated
Changed in git-upstream:
assignee: nobody → Aleksander Korzyński (akorzy)
status: New → In Progress
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix proposed to git-upstream (master)

Fix proposed to branch: master
Review: https://review.opendev.org/c/x/git-upstream/+/891660

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.