找不到满足 html-form-to-dict 要求的版本(来自版本:none)

Could not find a version that satisfies the requirement html-form-to-dict (from versions: none)

我刚刚将我的库移植到 Python 2.7

通过 pip install -e git+ssh://git@github.com/guettli/html_form_to_dict#egg=html_form_to_dict 安装适用于 Python 2.7.

但是如果我通过pip安装它会失败:

pip install -v html-form-to-dict


DEPRECATION: Python 2.7 reached the end of its life on January 1st, 2020. Please upgrade your Python as Python 2.7 is no longer maintained. pip 21.0 will drop support for Python 2.7 in January 2021. More details about Python 2 support in pip can be found at https://pip.pypa.io/en/latest/development/release-process/#python-2-support pip 21.0 will remove support for this functionality.
Using pip 20.3.4 from /root/tmp/foo/lib/python2.7/site-packages/pip (python 2.7)
Non-user install because user site-packages disabled
Created temporary directory: /tmp/pip-ephem-wheel-cache-gVgiT6
Created temporary directory: /tmp/pip-req-tracker-D6Ft0q
Initialized build tracking at /tmp/pip-req-tracker-D6Ft0q
Created build tracker: /tmp/pip-req-tracker-D6Ft0q
Entered build tracker: /tmp/pip-req-tracker-D6Ft0q
Created temporary directory: /tmp/pip-install-Busv66
1 location(s) to search for versions of html-form-to-dict:
* https://pypi.org/simple/html-form-to-dict/
Fetching project page and analyzing links: https://pypi.org/simple/html-form-to-dict/
Getting page https://pypi.org/simple/html-form-to-dict/
Found index url https://pypi.org/simple
Looking up "https://pypi.org/simple/html-form-to-dict/" in the cache
Request header has "max_age" as 0, cache bypassed
Starting new HTTPS connection (1): pypi.org:443
https://pypi.org:443 "GET /simple/html-form-to-dict/ HTTP/1.1" 304 0
  Skipping link: none of the wheel's tags match: py3-none-any: https://files.pythonhosted.org/packages/6e/bb/20b17baae8d33a65ef80f93a8bf80057c593629810ff4e0d0329ce0baf57/html_form_to_dict-2021.11.2-py3-none-any.whl#sha256=2868c4f54ee2f23c8a41a0f2fe21774e8f93618f7984174617b85f3c738e56e2 (from https://pypi.org/simple/html-form-to-dict/) (requires-python:>=3.6)
  Skipping link: none of the wheel's tags match: py3-none-any: https://files.pythonhosted.org/packages/0f/5f/89c1d7e853c9d340ad13a3695ddd5a8d47416432e89ec875010906c618cc/html_form_to_dict-2021.11.3-py3-none-any.whl#sha256=cda22bedd4416cb7116ed89c04f0c81d5dff9cbae0f7cc1c688024ea1267a64b (from https://pypi.org/simple/html-form-to-dict/) (requires-python:>=3.6)
  Skipping link: none of the wheel's tags match: py3-none-any: https://files.pythonhosted.org/packages/4f/29/0b2e1f221a6bb0f52476726942c6e951b5c8723ebaead381d5c0bb537a3e/html_form_to_dict-2021.11.4-py3-none-any.whl#sha256=5c3986c86cb0ed17a1656b2195e93b59634151d3b7c0be82a899874e1e7585d6 (from https://pypi.org/simple/html-form-to-dict/) (requires-python:>=3.6)
  Skipping link: none of the wheel's tags match: py3-none-any: https://files.pythonhosted.org/packages/23/cd/5d587384c7b3f41face8e9da0f25a0b8c27f9bfdc302a597873cbfa61ce9/html_form_to_dict-2021.11.5-py3-none-any.whl#sha256=aea97af4934e9b924e41bbd5e9c422e920a146a4e2e371f72a11d221ae67e9ca (from https://pypi.org/simple/html-form-to-dict/) (requires-python:>=3.6)
  Skipping link: none of the wheel's tags match: py3-none-any: https://files.pythonhosted.org/packages/73/a8/d2a97db900529cb964802ed987ad190ebae8793ca38ae42f8b22ca37b974/html_form_to_dict-2022.3.1-py3-none-any.whl#sha256=f5cbfa31856b30df10c096b13b46731ea353fdba85d33f49903fb251ee407e48 (from https://pypi.org/simple/html-form-to-dict/) (requires-python:>=2.7)
  Skipping link: none of the wheel's tags match: py3-none-any: https://files.pythonhosted.org/packages/9a/77/4c13df9f5342c19e89f9d0cf92cdb8826b7155dbbaf153b050e28d2a91ea/html_form_to_dict-2022.3.2-py3-none-any.whl#sha256=36be5262e592820616a9672b53114cb3e6dda56bbf5647d5b04715e83904eaf2 (from https://pypi.org/simple/html-form-to-dict/) (requires-python:>=2.7)
Given no hashes to check 0 links for project 'html-form-to-dict': discarding no candidates
ERROR: Could not find a version that satisfies the requirement html-form-to-dict (from versions: none)
ERROR: No matching distribution found for html-form-to-dict
Exception information:
Traceback (most recent call last):
  File "/root/tmp/foo/lib/python2.7/site-packages/pip/_internal/cli/base_command.py", line 223, in _main
    status = self.run(options, args)
  File "/root/tmp/foo/lib/python2.7/site-packages/pip/_internal/cli/req_command.py", line 180, in wrapper
    return func(self, options, args)
  File "/root/tmp/foo/lib/python2.7/site-packages/pip/_internal/commands/install.py", line 321, in run
    reqs, check_supported_wheels=not options.target_dir
  File "/root/tmp/foo/lib/python2.7/site-packages/pip/_internal/resolution/legacy/resolver.py", line 180, in resolve
    discovered_reqs.extend(self._resolve_one(requirement_set, req))
  File "/root/tmp/foo/lib/python2.7/site-packages/pip/_internal/resolution/legacy/resolver.py", line 385, in _resolve_one
    dist = self._get_dist_for(req_to_install)
  File "/root/tmp/foo/lib/python2.7/site-packages/pip/_internal/resolution/legacy/resolver.py", line 336, in _get_dist_for
    self._populate_link(req)
  File "/root/tmp/foo/lib/python2.7/site-packages/pip/_internal/resolution/legacy/resolver.py", line 302, in _populate_link
    req.link = self._find_requirement_link(req)
  File "/root/tmp/foo/lib/python2.7/site-packages/pip/_internal/resolution/legacy/resolver.py", line 267, in _find_requirement_link
    best_candidate = self.finder.find_requirement(req, upgrade)
  File "/root/tmp/foo/lib/python2.7/site-packages/pip/_internal/index/package_finder.py", line 929, in find_requirement
    req)
DistributionNotFound: No matching distribution found for html-form-to-dict
Removed build tracker: '/tmp/pip-req-tracker-D6Ft0q'

我能做些什么,让它可以安装到 Python 2.7?

顺便说一句,我在 setup.cfg 中使用了这个(所以这不是问题所在):

[options]
python_requires = >=2.7

我找到了答案。

如果您的版本转到“下载文件”,那么您可以看到哪些文件可用。

对我来说是这样的:https://pypi.org/project/html-form-to-dict/2022.3.1/#files

只有html_form_to_dict-2022.3.1-py3-none-any.whl

由于py3在这个文件名中,py2似乎无法安装它。

通过 twine 上传 tar.gz 后它起作用了:

python -m twine upload dist/html_form_to_dict-2022.3.2.tar.gz

更好的解决方案是构建一个万向轮,这样 py2 用户也可以从 .whl 安装而不是回退到 .tar.gz 版本。

为此,请在您的设置调用中添加:

# in setup.py
from setuptools import setup

setup(
    ...
    options={"bdist_wheel": {"universal": True}},
)

现在您的 wheel 文件将被命名为 html_form_to_dict-2022.3.1-py2.py3-none-any.whl,Python 2.7 用户也可以使用它。如果需要,您仍然可以同时上传 sdist (.tar.gz)。