pip >24.0 causes Expected matching RIGHT_PARENTHESIS for LEFT_PARENTHESIS, after version specifier kubernetes (>=9.0.0a1.0) ; extra == ‘all_extras’

I am trying to install prefect[kubernetes,azure]==1.4.0 using pip.

It get installed successfully with pip<=24.0.

However with any pip>24.0 the installation fails. For example:

# in a venv
pip install pip==24.2 # released on 2024-07-29
pip install prefect[kubernetes,azure]==1.4.0

results in

ERROR: Exception:
Traceback (most recent call last):
  File "/home/lambis/Projects/Prefect/prefect-flows/.venv/lib/python3.10/site-packages/pip/_vendor/pkg_resources/__init__.py", line 3367, in _dep_map
    return self.__dep_map
  File "/home/lambis/Projects/Prefect/prefect-flows/.venv/lib/python3.10/site-packages/pip/_vendor/pkg_resources/__init__.py", line 3147, in __getattr__
    raise AttributeError(attr)
AttributeError: _DistInfoDistribution__dep_map

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/lambis/Projects/Prefect/prefect-flows/.venv/lib/python3.10/site-packages/pip/_vendor/packaging/requirements.py", line 36, in __init__
    parsed = _parse_requirement(requirement_string)
  File "/home/lambis/Projects/Prefect/prefect-flows/.venv/lib/python3.10/site-packages/pip/_vendor/packaging/_parser.py", line 62, in parse_requirement
    return _parse_requirement(Tokenizer(source, rules=DEFAULT_RULES))
  File "/home/lambis/Projects/Prefect/prefect-flows/.venv/lib/python3.10/site-packages/pip/_vendor/packaging/_parser.py", line 80, in _parse_requirement
    url, specifier, marker = _parse_requirement_details(tokenizer)
  File "/home/lambis/Projects/Prefect/prefect-flows/.venv/lib/python3.10/site-packages/pip/_vendor/packaging/_parser.py", line 118, in _parse_requirement_details
    specifier = _parse_specifier(tokenizer)
  File "/home/lambis/Projects/Prefect/prefect-flows/.venv/lib/python3.10/site-packages/pip/_vendor/packaging/_parser.py", line 208, in _parse_specifier
    with tokenizer.enclosing_tokens(
  File "/usr/lib/python3.10/contextlib.py", line 142, in __exit__
    next(self.gen)
  File "/home/lambis/Projects/Prefect/prefect-flows/.venv/lib/python3.10/site-packages/pip/_vendor/packaging/_tokenizer.py", line 189, in enclosing_tokens
    self.raise_syntax_error(
  File "/home/lambis/Projects/Prefect/prefect-flows/.venv/lib/python3.10/site-packages/pip/_vendor/packaging/_tokenizer.py", line 167, in raise_syntax_error
    raise ParserSyntaxError(
pip._vendor.packaging._tokenizer.ParserSyntaxError: Expected matching RIGHT_PARENTHESIS for LEFT_PARENTHESIS, after version specifier
    kubernetes (>=9.0.0a1.0) ; extra == 'all_extras'
               ~~~~~~~~~~^

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/home/lambis/Projects/Prefect/prefect-flows/.venv/lib/python3.10/site-packages/pip/_internal/cli/base_command.py", line 105, in _run_wrapper
    status = _inner_run()
  File "/home/lambis/Projects/Prefect/prefect-flows/.venv/lib/python3.10/site-packages/pip/_internal/cli/base_command.py", line 96, in _inner_run
    return self.run(options, args)
  File "/home/lambis/Projects/Prefect/prefect-flows/.venv/lib/python3.10/site-packages/pip/_internal/cli/req_command.py", line 67, in wrapper
    return func(self, options, args)
  File "/home/lambis/Projects/Prefect/prefect-flows/.venv/lib/python3.10/site-packages/pip/_internal/commands/install.py", line 379, in run
    requirement_set = resolver.resolve(
  File "/home/lambis/Projects/Prefect/prefect-flows/.venv/lib/python3.10/site-packages/pip/_internal/resolution/resolvelib/resolver.py", line 95, in resolve
    result = self._result = resolver.resolve(
  File "/home/lambis/Projects/Prefect/prefect-flows/.venv/lib/python3.10/site-packages/pip/_vendor/resolvelib/resolvers.py", line 546, in resolve
    state = resolution.resolve(requirements, max_rounds=max_rounds)
  File "/home/lambis/Projects/Prefect/prefect-flows/.venv/lib/python3.10/site-packages/pip/_vendor/resolvelib/resolvers.py", line 427, in resolve
    failure_causes = self._attempt_to_pin_criterion(name)
  File "/home/lambis/Projects/Prefect/prefect-flows/.venv/lib/python3.10/site-packages/pip/_vendor/resolvelib/resolvers.py", line 239, in _attempt_to_pin_criterion
    criteria = self._get_updated_criteria(candidate)
  File "/home/lambis/Projects/Prefect/prefect-flows/.venv/lib/python3.10/site-packages/pip/_vendor/resolvelib/resolvers.py", line 229, in _get_updated_criteria
    for requirement in self._p.get_dependencies(candidate=candidate):
  File "/home/lambis/Projects/Prefect/prefect-flows/.venv/lib/python3.10/site-packages/pip/_internal/resolution/resolvelib/provider.py", line 247, in get_dependencies
    return [r for r in candidate.iter_dependencies(with_requires) if r is not None]
  File "/home/lambis/Projects/Prefect/prefect-flows/.venv/lib/python3.10/site-packages/pip/_internal/resolution/resolvelib/provider.py", line 247, in <listcomp>
    return [r for r in candidate.iter_dependencies(with_requires) if r is not None]
  File "/home/lambis/Projects/Prefect/prefect-flows/.venv/lib/python3.10/site-packages/pip/_internal/resolution/resolvelib/candidates.py", line 401, in iter_dependencies
    for r in self.dist.iter_dependencies():
  File "/home/lambis/Projects/Prefect/prefect-flows/.venv/lib/python3.10/site-packages/pip/_internal/metadata/pkg_resources.py", line 247, in iter_dependencies
    return self._dist.requires(extras)
  File "/home/lambis/Projects/Prefect/prefect-flows/.venv/lib/python3.10/site-packages/pip/_vendor/pkg_resources/__init__.py", line 3070, in requires
    dm = self._dep_map
  File "/home/lambis/Projects/Prefect/prefect-flows/.venv/lib/python3.10/site-packages/pip/_vendor/pkg_resources/__init__.py", line 3369, in _dep_map
    self.__dep_map = self._compute_dependencies()
  File "/home/lambis/Projects/Prefect/prefect-flows/.venv/lib/python3.10/site-packages/pip/_vendor/pkg_resources/__init__.py", line 3379, in _compute_dependencies
    reqs.extend(parse_requirements(req))
  File "/home/lambis/Projects/Prefect/prefect-flows/.venv/lib/python3.10/site-packages/pip/_vendor/pkg_resources/__init__.py", line 3434, in __init__
    super().__init__(requirement_string)
  File "/home/lambis/Projects/Prefect/prefect-flows/.venv/lib/python3.10/site-packages/pip/_vendor/packaging/requirements.py", line 38, in __init__
    raise InvalidRequirement(str(e)) from e
pip._vendor.packaging.requirements.InvalidRequirement: Expected matching RIGHT_PARENTHESIS for LEFT_PARENTHESIS, after version specifier
    kubernetes (>=9.0.0a1.0) ; extra == 'all_extras'
               ~~~~~~~~~~^

Not sure if this is the best solution but I ended up using the latest pip version where I could install the packages. For me that was pip==24.0, installed with pip install pip==24.0. WARNING: Run this only in a virtual environment and not in a global scope

The reason of the failure seems to be the changes introduced to pip==24.1b1 described here

pip has historically allowed many arbitrary strings as versions and version specifiers. Going forward, all versions and version specifiers will need to conform to https://packaging.python.org/en/latest/specifications/version-specifiers/ (based on PEP 440).

in combination with packages that force an incompatible version name. In my case, the prefect version I was trying to use, uses the incompatible kubernetes version name 9.0.0a1.0 here

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa
Thiết kế website Thiết kế website Thiết kế website Cách kháng tài khoản quảng cáo Mua bán Fanpage Facebook Dịch vụ SEO Tổ chức sinh nhật