Skip to content

'HTTPResponse' object has no attribute 'strict' #7936

Closed as not planned
Closed as not planned

Description

@aakashrshah
  • I am on the latest stable Poetry version, installed using a recommended method.
  • I have searched the issues of this repo and believe that this is not a duplicate.
  • I have consulted the FAQ and blog for any relevant entries or release notes.
  • If an exception occurs when executing a command, I executed it again in debug mode (-vvv option) and have included the output below.

Issue


  AttributeError

  'HTTPResponse' object has no attribute 'strict'

  at ~/Library/Caches/pypoetry/virtualenvs/rubber-duck-py3.10/lib/python3.10/site-packages/cachecontrol/serialize.py:54 in dumps
       50│                 ),
       51│                 u"status": response.status,
       52│                 u"version": response.version,
       53│                 u"reason": text_type(response.reason),
    →  54│                 u"strict": response.strict,
       55│                 u"decode_content": response.decode_content,
       56│             }
       57│         }
       58│ 

I am not able to install or add packages and blocked significantly. I do not see this issue on internet. Am i using a wrong python version? this is the latest version of poetry , shall i revert?

Activity

  1. added
    kind/bug
    status/triage
    on May 16, 2023
  2. dimbleby commented on May 16, 2023

    @dimbleby
    Contributor

    this is psf/cachecontrol#292

    however since poetry requirements do not allow urllib3 2.0, this shows that you, or whatever you used to install poetry, have upgraded something that you should not have done

    please close

  3. dimbleby commented on May 16, 2023

    @dimbleby
    Contributor

    PS I do not know why you write here "I do not see this issue on internet." when, as I now see, you have already commented on that other issue

  4. Secrus commented on May 17, 2023

    @Secrus
    Member

    Poetry has urllib3 pinned below 2.0, so you had to mess something up on your end (for example by installing your project and poetry into the same environment). In any case, this is not Poetry's fault.

  5. josumoreno-BP commented on May 17, 2023

    @josumoreno-BP

    Can be the case that you are still using poetry < 1.2; in that case you will need to pin urllib to < 2 because it was a dev dependency as you can see here.

  6. aakashrshah commented on May 17, 2023

    @aakashrshah
    Author

    Good by me if we want to close it. Currently I removed the line with strict in cache control.

    I tried it on python 3.10, 3.11 with latest poetry and latest pip.

    I don’t know what did I mess up on my end.

    Thanks though.

  7. aakashrshah commented on May 17, 2023

    @aakashrshah
    Author

    Can be the case that you are still using poetry < 1.2; in that case you will need to pin urllib to < 2 because it was a dev dependency as you can see here.

    I surely confirm I am using latest version 1.4.2 in and out(global) of my virtual environment.

  8. chanwutk commented on May 17, 2023

    @chanwutk

    @aakashrshah I am having the same issue (this issue started to happen a couple days ago).
    Would you mind if I ask you how did you "removed the line with strict in cache control", please?

  9. FachengG commented on May 18, 2023

    @FachengG

    @chanwutk
    Here is a solution for anyone faced similar problem:
    use None to replace response.strict.

    Not sure about side-effect, but it will work again.

  10. aakashrshah commented on May 18, 2023

    @aakashrshah
    Author

    @aakashrshah I am having the same issue (this issue started to happen a couple days ago).
    Would you mind if I ask you how did you "removed the line with strict in cache control", please?

    Hi @chanwutk

    I deleted line 54
    python3.10/site-packages/cachecontrol/serialize.py:54

  11. chanwutk commented on May 18, 2023

    @chanwutk

    Thank you!!

  12. added a commit that references this issue on May 18, 2023
  13. 21 remaining items

  14. tew9 commented on Aug 10, 2023

    @tew9

    I had the same issue, and I fix it by deleting the terminal I was running it from and rerun it in another terminal.
    It was a virtual environment issue for me.
    Issue: I was debugging using a terminal which is running poetry virtual environment.
    Fix: I deleted the terminal and create the new one that was on base environment and everything works fine.

    hope that helps

  15. ayub-kokabi commented on Sep 14, 2023

    @ayub-kokabi

    I've deleted all poetry virtual environments and created a new virtual environment again, and the problem was resolved.
    windows 11.

  16. bramses commented on Jan 4, 2024

    @bramses

    For me, I had moved my folder with poetry into a subfolder later on and for some reason that broke everything.

    1. poetry shell was in ~/folder_a
    2. i moved folder_a into ~/new_parent_folder/folder_a
    3. this broke poetry add, poetry install etc

    still not sure why. but when i moved it back to ~, it was fine again.

  17. hungiito commented on Jan 13, 2024

    @hungiito

    I had the same problem when installing poetry in a virtual environment. I found that when running poetry install in a virtual environment, poetry still use outdated urllib3 and requests installed in the machine. So I tried to upgrade urllib3 and requests (outside of virtual environment) and it works.

    In short

    deactivate # deactivate virtual env (if activated)
    pip3 install --upgrade pip
    pip3 install --upgrade urllib3 requests
  18. Telofy commented on Feb 6, 2024

    @Telofy

    I was about to fork Poetry and create a PR that adds the urllib3 = "^1.26.16" dependency to Poetry's pyproject.toml, but something tells me there's probably some recondite reason for the omission of the dependency? Or has just no one gotten around to adding it?

  19. Secrus commented on Feb 6, 2024

    @Secrus
    Member

    I was about to fork Poetry and create a PR that adds the urllib3 = "^1.26.16" dependency to Poetry's pyproject.toml, but something tells me there's probably some recondite reason for the omission of the dependency? Or has just no one gotten around to adding it?

    Yes, there reason is that this bug is not present in Poetry anymore. This is only a case for non-standard installation which are discouraged.

  20. Telofy commented on Feb 6, 2024

    @Telofy

    Oh, thx! There must've been something nonstandard about my environment because I used mamba/conda for another project. But now I'm running into #8679 instead of this one. ^.^

  21. LaoshuBaby commented on Mar 1, 2024

    @LaoshuBaby

    To above all, why not check pip install poetry urllib3 requests --upgrade? I meet with this issue today when I run "poetry install", I can't downgrade urllib3 because other part of project lock the dependency version, and only upgrade those 2 like hungiito wrote won't work.

    That's because I forgot to upgrade the most important poetry-1.4.1, and that version require urllib3<2.0.0,>=1.26.0

    But now the latest version of poetry is 1.8.1, and everythings work fluently, don't need to manually edit any link in site-packages. Now what about try to upgrade those 3 package all?

    ♥

  22. hungiito commented on Mar 2, 2024

    @hungiito

    @LaoshuBaby Have you tried upgrading urllib3 and requests outside of Poetry's virtual environment? In my case, I installed Poetry in a venv folder and noticed that Poetry uses the urllib3 in root environment rather than in venv directory

  23. LaoshuBaby commented on Mar 2, 2024

    @LaoshuBaby

    @LaoshuBaby Have you tried upgrading urllib3 and requests outside of Poetry's virtual environment? In my case, I installed Poetry in a venv folder and noticed that Poetry uses the urllib3 in root environment rather than in venv directory

    I did not specify a venv environment

  24. hungiito commented on Mar 3, 2024

    @hungiito

    @LaoshuBaby Have you tried upgrading urllib3 and requests outside of Poetry's virtual environment? In my case, I installed Poetry in a venv folder and noticed that Poetry uses the urllib3 in root environment rather than in venv directory

    I did not specify a venv environment

    Can you try upgrading both pip and poetry

    pip install --upgrade pip poetry
  25. LaoshuBaby commented on Mar 3, 2024

    @LaoshuBaby

    @hungiito

    To above all, why not check pip install poetry urllib3 requests --upgrade?
    -- In my reply #7936 (comment)

    I execute this command and upgrade everything to the latest, which can solve the problem originally raised by this issue.

    Can you try upgrading both pip and poetry

    You can do it without upgrading pip, but it will not cause problems if you upgrade it according to my test.

    (In short, now my pip, requests, urllib3, and poetry are all up to date.)

    That's why I recommend you upgrade(if you can) them.

  26. ChrCoello commented on Mar 5, 2024

    @ChrCoello

    As @jeromegit wrote earlier, this is surely due to using Poetry 1.4.
    Same error arose when we had to use conda (Azure ML Compute) as virtual environment manager (always try to avoid conda at any cost...). Then when one installs poetry on a freshly created conda environment using conda

    conda install poetry
    

    Poetry 1.4 is installed, by the same time downgrading urlib3 and requests.
    Using pip to install Poetry solved the "issue", installing latest Poetry 1.8 without any downgrade

    pip install poetry
  27. github-actions commented on Apr 5, 2024

    @github-actions

    This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

  28. locked as resolved and limited conversation to collaborators on Apr 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    kind/bugstatus/triage

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions