Search code examples
python-3.xinstallationpipversion

RuntimeError: Python version 2.7 or 3.4+ is required even if I already have 3.10.6 version


I'm running the installer as described in the guide present in the LabelPC's GitHub page on Ubuntu 22.04, but I get the following error:

Collecting absl-py==0.8.0
  Using cached absl-py-0.8.0.tar.gz (102 kB)
  Preparing metadata (setup.py) ... error
  error: subprocess-exited-with-error
  
  × python setup.py egg_info did not run successfully.
  │ exit code: 1
  ╰─> [6 lines of output]
      Traceback (most recent call last):
        File "<string>", line 2, in <module>
        File "<pip-setuptools-caller>", line 34, in <module>
        File "/tmp/pip-install-_yo1tcdy/absl-py_761c46388aa14bfaac46b6c57352037a/setup.py", line 34, in <module>
          raise RuntimeError('Python version 2.7 or 3.4+ is required.')
      RuntimeError: Python version 2.7 or 3.4+ is required.
      [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.

I don't know how to fix it, since everything is updated. My Python version is 3.10.6


Solution

  • This is a bug in abseil-py. Release 0.8 does Python version comparison this way. The comparison worked just fine for Pythons up to 3.9 but fails with 3.10+. When py_version is ('3', '10') the comparison returns False because in Python '10' is less then '4'; for strings Python compares '1' and '4'. (Integer 10 is of course > 4).

    The bug was fixed in commit d61b0b6. Unfortunately labelpc requires exact version 0.8. This means that for now abseil-py and labelpc can be used with Python 2.7 and 3.5-3.9 but not with 3.10+.

    Use Python 3.9 and report the bug.