python - 使用适用于 Azure 的 Python SDK 时发生 HTTP header 错误

标签 python linux azure

我从 Microsoft Azure SDK for Python ( https://github.com/Azure/azure-sdk-for-python ) 开始,但遇到了问题。

我使用的是 Scientific Linux,并且已按照以下步骤安装了适用于 Python 3.4 的 SDK:

(而不是SDK目录) python setup.py 安装

之后我创建了一个简单的脚本来测试连接:

from azure.storage import BlobService

blob_service = BlobService(account_name='thename', account_key='Mxxxxxxx3w==' )

blob_service.create_container('testcontainer')

for i in blob_service.list_containers():
        print(i.name)

遵循本文档: http://blogs.msdn.com/b/tconte/archive/2013/04/17/how-to-interact-with-windows-azure-blob-storage-from-linux-using-python.aspx http://azure.microsoft.com/en-us/documentation/articles/storage-python-how-to-use-blob-storage/#large-blobs

但不起作用,我总是收到相同的错误:

python3 test.py

Traceback (most recent call last):
  File "/usr/local/lib/python3.4/site-packages/azure-0.9.0-py3.4.egg/azure/storage/storageclient.py", line 143, in _perform_request
  File "/usr/local/lib/python3.4/site-packages/azure-0.9.0-py3.4.egg/azure/storage/storageclient.py", line 132, in _perform_request_worker
  File "/usr/local/lib/python3.4/site-packages/azure-0.9.0-py3.4.egg/azure/http/httpclient.py", line 247, in perform_request
azure.http.HTTPError: The value for one of the HTTP headers is not in the correct format.

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "test.py", line 21, in <module>
    blob_service.create_container('testcontainer')
  File "/usr/local/lib/python3.4/site-packages/azure-0.9.0-py3.4.egg/azure/storage/blobservice.py", line 192, in create_container
  File "/usr/local/lib/python3.4/site-packages/azure-0.9.0-py3.4.egg/azure/__init__.py", line 905, in _dont_fail_on_exist
  File "/usr/local/lib/python3.4/site-packages/azure-0.9.0-py3.4.egg/azure/storage/blobservice.py", line 189, in create_container
  File "/usr/local/lib/python3.4/site-packages/azure-0.9.0-py3.4.egg/azure/storage/storageclient.py", line 150, in _perform_request
  File "/usr/local/lib/python3.4/site-packages/azure-0.9.0-py3.4.egg/azure/storage/__init__.py", line 889, in _storage_error_handler
  File "/usr/local/lib/python3.4/site-packages/azure-0.9.0-py3.4.egg/azure/__init__.py", line 929, in _general_error_handler
azure.WindowsAzureError: Unknown error (The value for one of the HTTP headers is not in the correct format.)
<?xml version="1.0" encoding="utf-8"?><Error><Code>InvalidHeaderValue</Code><Message>The value for one of the HTTP headers is not in the correct format.
RequestId:b37c5584-0001-002b-24b8-c2c245000000
Time:2014-11-19T14:54:38.9378626Z</Message><HeaderName>x-ms-version</HeaderName><HeaderValue>2012-02-12</HeaderValue></Error>

提前致谢并致以最诚挚的问候。

最佳答案

我也有同样的问题。我相信这是一个库错误,但作者还没有发表意见。

看起来响应指出了版本,但实际上它给你的 header 是错误的。它的值应该是“2014-02-14”,您可以执行 https://github.com/Azure/azure-sdk-for-python/pull/289 中所示的修复。 .

希望这个问题能够得到解决,并且没有人会读到这个答案。干杯!

关于python - 使用适用于 Azure 的 Python SDK 时发生 HTTP header 错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27044226/

相关文章:

java - 如何从 linux 提示符中终止 java 程序

ajax - 当用户登录到 Web 应用程序时通过 AJAX 访问 .NET Core Web API

azure - Analysis Service 表格多维数据集刷新状态检查

python - ImportError : No module named win32com. 客户端

python - 在 Python 中序列化 float 安全吗?

linux - Alpine Linux 3.7 上的 Docker 容器 : Strange pid 1 not visible within the container's pid namespace

c++ - 是否可以在 Linux 中将数据写入自己的标准输入

azure - 是否可以浏览 Azure 应用服务临时目录?

python和redis,语法不清楚

Python:动态存储字典的访问