pip-compile error: AttributeError: 'ParsedRequirement' object has no attribute 'editable'

pip-compile error: AttributeError: 'ParsedRequirement' object has no attribute 'editable'

我正在尝试使用 pip-compile 构建我的 requirements.txt 文件,但出现以下错误。

Traceback (most recent call last):
  File "/Users/foobar/.pyenv/versions/3.7.0/bin/pip-compile", line 11, in <module>
    sys.exit(cli())
  File "/Users/foobar/.pyenv/versions/3.7.0/lib/python3.7/site-packages/click/core.py", line 764, in __call__
    return self.main(*args, **kwargs)
  File "/Users/foobar/.pyenv/versions/3.7.0/lib/python3.7/site-packages/click/core.py", line 717, in main
    rv = self.invoke(ctx)
  File "/Users/foobar/.pyenv/versions/3.7.0/lib/python3.7/site-packages/click/core.py", line 956, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/Users/foobar/.pyenv/versions/3.7.0/lib/python3.7/site-packages/click/core.py", line 555, in invoke
    return callback(*args, **kwargs)
  File "/Users/foobar/.pyenv/versions/3.7.0/lib/python3.7/site-packages/click/decorators.py", line 17, in new_func
    return f(get_current_context(), *args, **kwargs)
  File "/Users/foobar/.pyenv/versions/3.7.0/lib/python3.7/site-packages/piptools/scripts/compile.py", line 305, in cli
    for ireq in filter(is_pinned_requirement, ireqs):
  File "/Users/foobar/.pyenv/versions/3.7.0/lib/python3.7/site-packages/piptools/utils.py", line 122, in is_pinned_requirement
    if ireq.editable:
AttributeError: 'ParsedRequirement' object has no attribute 'editable'

我尝试根据pip-tools pypi网站一起降级pip和pip-tools,但我似乎无法克服这个错误。如果有人有建议,他们将不胜感激。

点数列表

Package                 Version
----------------------- -----------
aiohttp                 3.7.4.post0
alembic                 1.4.3
asn1crypto              1.4.0
async-timeout           3.0.1
attrs                   21.2.0
certifi                 2021.5.30
chardet                 3.0.4
click                   8.0.1
colorama                0.4.3
coverage                5.5
flake8                  3.8.3
greenlet                1.1.0
idna                    2.10
importlib-metadata      4.6.1
Mako                    1.1.4
MarkupSafe              2.0.1
mccabe                  0.6.1
more-itertools          8.8.0
multidict               5.1.0
packaging               21.0
pep517                  0.11.0
pg8000                  1.20.0
pip                     21.0.1
pip-tools               6.1.0
pluggy                  0.13.1
psycopg2                2.8.5
py                      1.10.0
pycodestyle             2.6.0
pyflakes                2.2.0
PyJWT                   1.7.1
pyparsing               2.4.7
pytest                  5.4.3
pytest-cov              2.12.0
pytest-mock             3.1.1
python-dateutil         2.8.2
python-editor           1.0.4
requests                2.24.0
scramp                  1.4.0
setuptools              39.0.1
six                     1.16.0
slack-sdk               3.11.0
SQLAlchemy              1.4.20
testing.common.database 2.0.3
testing.postgresql      1.3.0
toml                    0.10.2
tomli                   1.2.1
typing-extensions       3.10.0.0
urllib3                 1.25.11
wcwidth                 0.2.5
wheel                   0.37.0
yarl                    1.6.3
zipp                    3.5.0

错误来自 pip-tools 试图访问 class ParsedRequirement 上的 editable 属性,而 class 上的正确属性名称是is_editable。对于 pip 的早期版本,ireq 处的对象属于 InstallRequirement 类型, 具有属性 editable.

尝试pip==20.0.2;这似乎是从相关方法 (parse_requirements) 返回 InstallRequirement 而不是 ParsedRequirement 的最后一个版本。