【问题标题】:Using Python-Package in Azure WebJobs showing Eror - ImportError: DLL load failed在 Azure WebJobs 中使用 Python 包显示错误 - ImportError: DLL load failed
【发布时间】:2018-03-13 07:25:01
【问题描述】:

我正在使用 python 脚本创建 azure WebJobs。这需要像 azure-storage-blob 和 pandas 这样的包。为了使用这些软件包,我按照链接 Python libraries on Web Jobhttps://lnx.azurewebsites.net/python-site-packages-in-azure-python-webjobs/ 上给出的说明进行操作。

错误

[03/13/2018 05:30:00 > a941f1: SYS INFO] 状态更改为 初始化 [03/13/2018 05:30:02 > a941f1: SYS INFO] 作业目录 检测到更改:作业文件 'some\site-packages\six.pyc' 时间戳 源目录和工作目录不同。 [03/13/2018 05:30:36 > a941f1:SYS INFO] 使用脚本主机运行脚本“run.cmd”- 'WindowsScriptHost' [03/13/2018 05:30:36 > a941f1: SYS INFO] 状态 更改为运行 [03/13/2018 05:30:36 > a941f1: INFO] [03/13/2018 05:30:36 > a941f1:信息] D:\local\Temp\jobs\triggered\blob\okznsh2a.kix\some>D:\home\Python27\python.exe blob.py [03/13/2018 05:30:38 > a941f1: ERR ] 回溯(最近 最后通话):[03/13/2018 05:30:38 > a941f1:ERR] 文件“blob.py”, 第 4 行,在 [03/13/2018 05:30:38 > a941f1: ERR ] 来自 azure.storage.blob 导入 BlockBlobService,ContentSettings [03/13/2018 05:30:38 > a941f1: ERR ] 文件 “site-packages\azure\storage\blob__init__.py”,第 6 行,在 [03/13/2018 05:30:38 > a941f1: ERR ] 来自 .appendblobservice 导入 AppendBlobService [03/13/2018 05:30:38 > a941f1: ERR ] 文件 “site-packages\azure\storage\blob\appendblobservice.py”,第 30 行,在 [03/13/2018 05:30:38 > a941f1: ERR ] 来自 ._deserialization 导入([03/13/2018 05:30:38 > a941f1: ERR] 文件 “site-packages\azure\storage\blob_deserialization.py”,第 39 行,在 [03/13/2018 05:30:38 > a941f1: ERR ] 来自 ._encryption 导入_decrypt_blob [03/13/2018 05:30:38 > a941f1: ERR] 文件 “site-packages\azure\storage\blob_encryption.py”,第 13 行,在 [03/13/2018 05:30:38 > a941f1: ERR ] 来自 cryptography.hazmat.primitives.padding 导入 PKCS7 [03/13/2018 05:30:38 > a941f1: ERR ] 文件 “site-packages\cryptography\hazmat\primitives\padding.py”,第 13 行,在 [03/13/2018 05:30:38 > a941f1: ERR ] 来自 cryptography.hazmat.bindings._padding 导入库 [03/13/2018 05:30:38

a941f1: ERR ] ImportError: DLL load failed: 找不到指定的模块。 [03/13/2018 05:30:38 > a941f1: SYS INFO] 状态 更改为失败 [03/13/2018 05:30:38 > a941f1: SYS ERR] 作业失败 由于退出代码 1

我在 Azure 中查找 ImportError: DLL load failed 但我没有得到任何与此问题相关的令人信服的答案。其中大多数与升级某些包有关。我用于为 Webjobs 上传的文件夹具有以下内容

blob.py
run.cmd
site-packages

文件

run.cmd 包含:

D:\home\Python27\python.exe blob.py

blob.py

enter code here
import sys
sys.path.append("site-packages")
from azure.storage.blob import BlockBlobService,ContentSettings
import pandas as pd
from io import StringIO
class blobfunction:
        def __init__(self,account,key):

            self.block_blob_service = BlockBlobService(account_name=account, account_key=key)

如何使用 blob.py 脚本运行 azure Webjobs?

【问题讨论】:

  • 嗨,现在有进展吗?

标签: python-2.7 azure azure-webjobs


【解决方案1】:

我在我这边测试了类似的代码,webjobs 很适合我。

根据您提供的路径,我可以看到您正在 Web 应用中安装 Python27 扩展。

我安装了python2.7.14*86版本,通过pip安装了azure-storage包。

run.cmd:

D:\home\Python27\python.exe sample.py

sample.py:(这里不需要添加路径,因为依赖包安装在上面cmd中设置的默认路径)

from azure.storage.blob import BlockBlobService,ContentSettings

block_blob_service = BlockBlobService(account_name='***', account_key='***')

generator = block_blob_service.list_blobs('jay')
for blob in generator:
    print "\t Blob name: " , blob.name

运行网络作业:

希望对你有帮助。

【讨论】:

  • 太棒了,所以你的意思是我们需要将 mydemo.py 文件上传到 python 目录中,在 webjob 中我们需要上传带有 python exe 路径的 run.cmd 文件,如D:\home\python364x64\python.exe mydemo.py 对吗?
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2017-10-18
相关资源
最近更新 更多