简体   繁体   English

在 azure 函数中导入 python 包

[英]import python packages in azure function

i am trying to use our custom python package in azure function but it is saying modulenotfounderror我正在尝试在 azure 函数中使用我们的自定义 python 包,但它说 modulenotfounderror

strcuture:结构:

import azure.functions as func
from pythonpackage.featureimpl import  feature as f

but it showed me error Exception: ModuleNotFoundError: No module named 'pythonpackage'但它向我显示了错误异常:ModuleNotFoundError: No module named 'pythonpackage'

where should i put these python packages so that it can be imported into azure funtion我应该把这些 python 包放在哪里,以便它可以导入到 azure 函数中

  1. If 'pythonpackage'' is a public module that can be installed using pip, you should include it in the requirements.txt file.如果“pythonpackage”是可以使用 pip 安装的public module ,则应将其包含在requirements.txt文件中。
    Microsoft Documentation Reference , 微软文档参考

  2. If 'pythonpackage'' is a self-created module , then it is a python relative import query.如果'pythonpackage''是一个self-created module ,那么它是一个python相对导入查询。 You must include in a folder and ensure that the folder is accessible.您必须包含在一个文件夹中并确保该文件夹是可访问的。

dir_path = os.path.dirname(os.path.realpath(__file__))  
sys.path.insert(0, dir_path)

import azure.functions as func  
from pythonpackage.featureimpl import feature as f  

For further information refer these Import custom modules in azure python-function and Import module into python azure-function .有关详细信息,请参阅这些Import custom modules in azure python-functionImport module into python azure-function

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM