azure-sdk-for-python icon indicating copy to clipboard operation
azure-sdk-for-python copied to clipboard

azure 1.0.3 is not compatible with requests >= 2.11.0

Open c-n-d opened this issue 10 years ago • 3 comments

Hi Team,

It seems that azure==1.0.3 and requests>=2.11.0 are incompatible. The code sample below successfully executes with requests==2.10.0.

# Offending code sample
self.resource_client = azure.mgmt.resource.ResourceManagementClient(self.creds)
...

result = self.resource_client.resource_groups.create_or_update(
    group_name,
    azure.mgmt.resource.ResourceGroup(
        location=region,
     ),
)
$ pip show azure

---
Metadata-Version: 1.1
Name: azure
Version: 1.0.3
Summary: Microsoft Azure Client Libraries for Python
Home-page: https://github.com/Azure/azure-sdk-for-python
Author: Microsoft Corporation
Author-email: [email protected]
License: Apache License 2.0
Location: /Library/Python/2.7/site-packages
Requires: azure-mgmt, azure-servicebus, azure-storage, azure-servicemanagement-legacy
...

$ pip show requests

---
Metadata-Version: 2.0
Name: requests
Version: 2.11.0
Summary: Python HTTP for Humans.
Home-page: http://python-requests.org
Author: Kenneth Reitz
Author-email: [email protected]
Installer: pip
License: Apache 2.0
Location: /Library/Python/2.7/site-packages
Requires: 
...

$ python azure_demo.py
...
 File "/Library/Python/2.7/site-packages/azure/mgmt/resource/resourcemanagement.py", line 5049, in create_or_update
    response = self.client.send_request(http_request)
  File "/Library/Python/2.7/site-packages/azure/mgmt/common/__init__.py", line 176, in send_request
    prepared_request = self._session.prepare_request(http_request)
  File "/Library/Python/2.7/site-packages/requests/sessions.py", line 390, in prepare_request
    hooks=merge_hooks(request.hooks, self.hooks),
  File "/Library/Python/2.7/site-packages/requests/models.py", line 295, in prepare
    self.prepare_headers(headers)
  File "/Library/Python/2.7/site-packages/requests/models.py", line 409, in prepare_headers
    check_header_validity(header)
  File "/Library/Python/2.7/site-packages/requests/utils.py", line 756, in check_header_validity
    "not %s" % (value, type(value)))
requests.exceptions.InvalidHeader: Header value 22 must be of type str or bytes, not <type 'int'>

Please let me know if you need any additional information.

Thanks!

c-n-d avatar Aug 28 '16 23:08 c-n-d

The relevant change in requests is documented here, and was implemented in requests PR 3390.

bbayles avatar Aug 29 '16 01:08 bbayles

Hi @c-n-d @bbayles

Yes, the package azure-mgmt-resource 0.20.x you use is not compatible with requests 2.11.0. I already had a conversation with the requests team on this.

Note that this version of this package was released as a preview package only (see the "This is a preview release" section on PyPI). I strongly suggest you to move to the latest preview of this package 0.30.0rc5. This package will be released as 1.0.0 stable soon and is the recommended way to use Resource and ARM.

lmazuel avatar Aug 29 '16 14:08 lmazuel

Hi @c-n-d @bbayles

Another solution I didn't write is to force your dependencies to use requests 2.10. You can write something like this in a requirements.txt file

requests<2.11.0

I wrote a more detailed page on our readthedocs website about the packages status http://azure-sdk-for-python.readthedocs.io/en/latest/installation.html

I close this issue, since we will not fix ARM packages 0.20.x that were in preview. Please feel free to open any bugs or questions you have with the new packages.

Thank you for your support!

lmazuel avatar Sep 06 '16 20:09 lmazuel