Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/azure/12.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 3.x Azure Python函数(Linux)中的导入模块错误_Python 3.x_Azure_Visual Studio Code_Azure Functions_Python Import - Fatal编程技术网

Python 3.x Azure Python函数(Linux)中的导入模块错误

Python 3.x Azure Python函数(Linux)中的导入模块错误,python-3.x,azure,visual-studio-code,azure-functions,python-import,Python 3.x,Azure,Visual Studio Code,Azure Functions,Python Import,我已经在我的Windows机器上使用VS代码创建了Python队列触发器。为了安装模块,我创建了虚拟环境,pip安装了所有需要的模块。我在消费计划中将此functionApp从VSCode部署到Linux操作系统上的Azure。当我从Azure运行此函数时,它会抛出导入模块错误,如果它没有获取模块,则我不会。没有Kudu可用于安装模块。我已将所有模块版本放在Requirement.txt中。 Requirement.txt- azure-common==1.1.25 azure-core==1.

我已经在我的Windows机器上使用VS代码创建了Python队列触发器。为了安装模块,我创建了虚拟环境,pip安装了所有需要的模块。我在消费计划中将此functionApp从VSCode部署到Linux操作系统上的Azure。当我从Azure运行此函数时,它会抛出导入模块错误,如果它没有获取模块,则我不会。没有Kudu可用于安装模块。我已将所有模块版本放在Requirement.txt中。 Requirement.txt-

azure-common==1.1.25
azure-core==1.4.0
azure-functions==1.2.0
azure-nspkg==3.0.2
azure-storage==0.36.0
azure-storage-blob==12.3.0
azure-storage-common==2.1.0
certifi==2020.4.5.1
cffi==1.14.0
chardet==3.0.4
cryptography==2.9.2
idna==2.9
isodate==0.6.0
msrest==0.6.13
numpy==1.18.3
oauthlib==3.1.0
pandas==1.0.3
pip==19.2.3
pycparser==2.20
python-dateutil==2.8.1
pytz==2020.1
requests==2.23.0
requests-oauthlib==1.3.0
setuptools==41.2.0
six==1.14.0
urllib3==1.25.9
wheel==0.34.2
我的虚拟环境文件夹与所有函数处于同一级别,我使用的是python 3.6。 代码截图-

import os

import platform
import json
import requests
import datetime
import pandas as pd
import numpy as np
from datetime import timedelta
from pandas import json_normalize
from azure.storage.blob import BlockBlobService, AppendBlobService
import azure.functions as func


# read the queue message and write to stdout
def main(msg: func.QueueMessage):
    print ("ShiftAdmitPreprocessingWest - started")
    blobaccess = msg.get_json()
来自Azure的错误-

Result: Failure
Exception: ImportError: cannot import name 'BlockBlobService' from 'azure.storage.blob' (/home/site/wwwroot/.python_packages/lib/site-packages/azure/storage/blob/__init__.py)
Stack:   File "/azure-functions-host/workers/python/3.7/LINUX/X64/azure_functions_worker/dispatcher.py", line 242, in _handle__function_load_request
    func_request.metadata.entry_point)
  File "/azure-functions-host/workers/python/3.7/LINUX/X64/azure_functions_worker/loader.py", line 66, in load_function
    mod = importlib.import_module(fullmodname)
  File "/usr/local/lib/python3.7/importlib/__init__.py", line 127, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 1006, in _gcd_import
  File "<frozen importlib._bootstrap>", line 983, in _find_and_load
  File "<frozen importlib._bootstrap>", line 953, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
  File "<frozen importlib._bootstrap>", line 1006, in _gcd_import
  File "<frozen importlib._bootstrap>", line 983, in _find_and_load
  File "<frozen importlib._bootstrap>", line 967, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 677, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 728, in exec_module
  File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
  File "/home/site/wwwroot/ShiftAdmitPreprocessingWest/__init__.py", line 14, in <module>
    from azure.storage.blob import BlockBlobService, AppendBlobService
结果:失败
异常:导入错误:无法从“azure.storage.blob”(/home/site/wwwroot/.python\u packages/lib/site packages/azure/storage/blob/\uuuu init\uuuu.py)导入名称“BlockBlobService”)
堆栈:文件“/azure functions host/workers/python/3.7/LINUX/X64/azure\u functions\u worker/dispatcher.py”,第242行,在\u handle\u function\u load\u请求中
func_请求.元数据.入口点)
文件“/azure functions host/workers/python/3.7/LINUX/X64/azure\u functions\u worker/loader.py”,第66行,在load\u函数中
mod=importlib.import\u模块(fullmodname)
文件“/usr/local/lib/python3.7/importlib/_init__uuu.py”,第127行,在导入模块中
return _bootstrap._gcd_import(名称[级别:],包,级别)
文件“”,第1006行,在\u gcd\u导入中
文件“”,第983行,在_find_和_load中
文件“”,第953行,在“查找”和“加载”中解锁
文件“”,第219行,在“调用”中,删除了“帧”
文件“”,第1006行,在\u gcd\u导入中
文件“”,第983行,在_find_和_load中
文件“”,第967行,在“查找”和“加载”中解锁
文件“”,第677行,在\u加载\u解锁
exec_模块中第728行的文件“”
文件“”,第219行,在“调用”中,删除了“帧”
文件“/home/site/wwwroot/ShiftAdmitPreprocessingWest/_init__.py”,第14行,在
从azure.storage.blob导入BlockBlobsService、AppendBlobsService
你能用这种方法试试吗

from azure.storage.blob.blockblobservice import BlockBlobService
你能用这种方法试试吗

from azure.storage.blob.blockblobservice import BlockBlobService

我当然会试试。是否有任何原因表明“从azure.storage.blob导入BlockBlobbService”在本地VS代码中有效,但在azure中无效?我是否需要为此在需求文件中添加任何其他dll,或者需要在部署此更改之前在VS代码中安装它们?谢谢是的,您需要安装这些软件包,您可以通过kudu控制台来检查它是否工作。非常感谢。我刚刚将azure.storage.blob更改为azure.storage.blob.BlockBlobsService。我没有从Kudu安装任何东西。Linux消费计划禁用了Kudu。非常感谢。伟大的很高兴有帮助,如果答案有帮助,请投票。我一定会试试。是否有任何原因表明“从azure.storage.blob导入BlockBlobbService”在本地VS代码中有效,但在azure中无效?我是否需要为此在需求文件中添加任何其他dll,或者需要在部署此更改之前在VS代码中安装它们?谢谢是的,您需要安装这些软件包,您可以通过kudu控制台来检查它是否工作。非常感谢。我刚刚将azure.storage.blob更改为azure.storage.blob.BlockBlobsService。我没有从Kudu安装任何东西。Linux消费计划禁用了Kudu。非常感谢。伟大的很高兴它有帮助,如果答案有帮助,请向上投票。包含的信息量很大,但如果你重新措辞以包含一个特定的问题来回答,则会有所帮助。包含的信息量很大,但如果你重新措辞以包含一个特定的问题来回答,则会有所帮助。