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

1.3k views Asked by At

I'm trying to use pip-compile to build my requirements.txt file and I get the following error.

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==21.2.4
  • pip-tools==6.2.0

I tried downgrading pip and pip-tools according to the pip-tools pypi website together but I can't seem to overcome this error. If anyone has suggestions, they'd be much appreciated.

Pip List

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
1

There are 1 answers

0
Angus L'Herrou On BEST ANSWER

The error comes from pip-tools trying to access the editable attribute on the class ParsedRequirement, whereas the correct attribute name on that class is is_editable. With previous versions of pip, the object at ireq were of type InstallRequirement, which does have the attribute editable.

Try pip==20.0.2; that seems to be the last version that returned InstallRequirement instead of ParsedRequirement from the relevant method (parse_requirements).