gpt4 book ai didi

python - 从 SQL Server 代理运行代码时出现问题 - azure.storage.blob - 找不到模块 azure

转载 作者:行者123 更新时间:2023-12-03 02:19:46 24 4
gpt4 key购买 nike

我在连接到 azure 存储容器的一些 python 代码时遇到问题。

代码:

from azure.storage.blob import BlockBlobService
import logging
import os, sys

block_blob_service = BlockBlobService(account_name = accountName, account_key = accountKey, connection_string=connectionString)

block_blob_service.create_blob_from_path(containerName,blob_name=blobName,file_path=fileNameToUpload)

好的,所以这段代码在使用命令提示符执行时可以工作。

当使用 SQL 代理作业执行时:

line 1, in from azure.storage.blob import BlockBlobService ModuleNotFoundError: No module named 'azure'. Process Exit Code 1. The step failed.

点列表:

azure-common         1.1.27
azure-core 1.19.0
azure-storage-blob 1.5.0
azure-storage-common 1.4.2

使用Python 3.7.4

我用来运行 SQL 代理作业的凭据已映射到我的用户 ID,该用户 ID 在服务器上具有管理员权限。

我用了the quickstart让我开始。

有人可以帮忙吗?

最佳答案

您引用的是旧版本的 azure.storage.version v1.5.0,在最新版本 v12.x.x 中,您需要改用 BlobServiceClient

######################################
pip install azure-storage-blob==12.9.0
######################################

blob_service_client = BlobServiceClient(account_url=url, credential=self._account_key)

您提到的链接已经指向最新版本

关于python - 从 SQL Server 代理运行代码时出现问题 - azure.storage.blob - 找不到模块 azure,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/69551828/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com