首页 > 解决方案 > 无法使用 Python 在 Azure Blob 存储上创建容器

问题描述

我正在尝试在 Azure Blob 存储中创建一个容器。这是代码片段 -

from azure.storage.blob import BlobServiceClient

import uuid

connect_str = 'xxxxxx'

#create a container
blob_service_client = BlobServiceClient.from_connection_string(connect_str)
container_name = "quickstart" + str(uuid.uuid4())
container_client = blob_service_client.create_container(container_name)

我收到以下错误 -

ImportError: No module named 'azure.storage'; 'azure' is not a package

我已经安装了 azure-storage-blob 包。我究竟做错了什么?

* python -m pip show azure-storage-blob* 的输出是 -

(venv) C:\Users\riz\PycharmProjects\azure_blob_extract>python -m pip show azure-storage-blob
Name: azure-storage-blob
Version: 12.3.2
Summary: Microsoft Azure Blob Storage Client Library for Python
Home-page: https://github.com/Azure/azure-sdk-for-python/tree/master/sdk/storage/azure-storage-blob
Author: Microsoft Corporation
Author-email: ascl@microsoft.com
License: MIT License
Location: c:\users\riz\pycharmprojects\azure_blob_extract\venv\lib\site-packages
Requires: cryptography, msrest, azure-core
Required-by:

* python --version * 的输出是 -

Python 3.7.4

当我尝试从 Windows CMD 运行代码时,出现此错误 -

azure.core.exceptions.ServiceRequestError: ("bad handshake: Error([('SSL routines', 'tls_process_server_certificate', 'certificate verify failed')])",)

当我从 PyCharm IDE 运行代码时,出现此错误-

azure.core.exceptions.ServiceRequestError: <urllib3.connection.HTTPSConnection object at 0x000001EEA3C9AC88>: Failed to establish a new connection: [WinError 10013] An attempt was made to access a socket in a way forbidden by its access permissions

标签: python-3.xazureazure-blob-storage

解决方案


推荐阅读