getting import error in Azure Functions

SangeethaP 40 Reputation points
2023-10-06T11:49:21.28+00:00

Is there any document where I can refer to what are all the python libraries and packages that are being supported in Azure Functions?

in my script, I am using the below libraries, but while triggering the Azure Function, I am getting the error in the import statement

requirements.txt:

azure-functions
python-tabular
pyadomd
msal
numpy
pandas
pymsteams
azure-storage-blob

import statement inside the code:

import pytabular
from pyadomd import Pyadomd
import requests
import json
import msal
import logging
import numpy as np
import pandas as pd
import sys
import pymsteams
from azure.storage.blob import BlobServiceClient, ContainerClient, ContentSettings
import io

Error got while triggering the function:

Full Exception :
 Exception while executing function
 /Functions.httpTrigger ---> Microsoft.Azure.WebJobs.Script.Workers.Rpc.RpcException 
 /Result
 /Failure Exception
 /RuntimeError
 /Could not find libmono 

 /  
 '/azure-functions-host/workers/python/3.10/LINUX/X64/azure_functions_worker/dispatcher.py', line 380, in _handle__function_load_request     func = loader.load_function(   
 '/azure-functions-host/workers/python/3.10/LINUX/X64/azure_functions_worker/utils/wrappers.py', line 44, in call     return func(*args, **kwargs)   
 '/azure-functions-host/workers/python/3.10/LINUX/X64/azure_functions_worker/loader.py', line 132, in load_function     mod = importlib.import_module(fullmodname)   
 '/usr/local/lib/python3.10/importlib/__init__.py', line 126, in import_module     return _bootstrap._gcd_import(name[level:], package, level)   
 '<frozen importlib._bootstrap>', line 1050, in _gcd_import   
 '<frozen importlib._bootstrap>', line 1027, in _find_and_load   
 '<frozen importlib._bootstrap>', line 1006, in _find_and_load_unlocked   
 '<frozen importlib._bootstrap>', line 688, in _load_unlocked   
 '<frozen importlib._bootstrap_external>', line 883, in exec_module   
 '<frozen importlib._bootstrap>', line 241, in _call_with_frames_removed   
 '/home/site/wwwroot/httpTrigger/__init__.py', line 9, in <module>     from .refresh_automation import main_func   
 '/home/site/wwwroot/httpTrigger/refresh_automation.py', line 6, in <module>     import pytabular   
 '/home/site/wwwroot/.python_packages/lib/site-packages/pytabular/__init__.py', line 45, in <module>     import clr   
 '/home/site/wwwroot/.python_packages/lib/site-packages/clr.py', line 6, in <module>     load()   
 '/home/site/wwwroot/.python_packages/lib/site-packages/pythonnet/__init__.py', line 36, in load     set_default_runtime()   
 '/home/site/wwwroot/.python_packages/lib/site-packages/pythonnet/__init__.py', line 22, in set_default_runtime     set_runtime(clr_loader.get_mono())   
 '/home/site/wwwroot/.python_packages/lib/site-packages/clr_loader/__init__.py', line 21, in get_mono     libmono = find_libmono(sgen)   
 '/home/site/wwwroot/.python_packages/lib/site-packages/clr_loader/util/find.py', line 67, in find_libmono     raise RuntimeError('Could not find libmono')     
System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()    
async Microsoft.Azure.WebJobs.Script.Description.WorkerFunctionInvoker.InvokeCore(Object[] parameters,FunctionInvocationContext context) 
/src/azure-functions-host/src/WebJobs.Script/Description/Workers/WorkerFunctionInvoker.cs 
 /101    
System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()    
async Microsoft.Azure.WebJobs.Script.Description.FunctionInvokerBase.Invoke(Object[] parameters) 
/src/azure-functions-host/src/WebJobs.Script/Description/FunctionInvokerBase.cs 
 /82    
System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()    
async Microsoft.Azure.WebJobs.Script.Description.FunctionGenerator.Coerce[T](Task`1 src) 
/src/azure-functions-host/src/WebJobs.Script/Description/FunctionGenerator.cs 
 /225    
System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()    
async Microsoft.Azure.WebJobs.Host.Executors.FunctionInvoker`2.InvokeAsync[TReflected,TReturnValue](Object instance,Object[] arguments) 
D:\a\_work\1\s\src\Microsoft.Azure.WebJobs.Host\Executors\FunctionInvoker.cs 
 /52    
System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()    
async Microsoft.Azure.WebJobs.Host.Executors.FunctionExecutor.InvokeWithTimeoutAsync(IFunctionInvoker invoker,ParameterHelper parameterHelper,CancellationTokenSource timeoutTokenSource,CancellationTokenSource functionCancellationTokenSource,Boolean throwOnTimeout,TimeSpan timerInterval,IFunctionInstance instance) 
D:\a\_work\1\s\src\Microsoft.Azure.WebJobs.Host\Executors\FunctionExecutor.cs 
 /581    
System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()    
async Microsoft.Azure.WebJobs.Host.Executors.FunctionExecutor.ExecuteWithWatchersAsync(IFunctionInstanceEx instance,ParameterHelper parameterHelper,ILogger logger,CancellationTokenSource functionCancellationTokenSource) 
D:\a\_work\1\s\src\Microsoft.Azure.WebJobs.Host\Executors\FunctionExecutor.cs 
 /527    
System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()    
async Microsoft.Azure.WebJobs.Host.Executors.FunctionExecutor.ExecuteWithLoggingAsync(IFunctionInstanceEx instance,FunctionStartedMessage message,FunctionInstanceLogEntry instanceLogEntry,ParameterHelper parameterHelper,ILogger logger,CancellationToken cancellationToken) 
D:\a\_work\1\s\src\Microsoft.Azure.WebJobs.Host\Executors\FunctionExecutor.cs 
 /306    End of inner exception    
System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()    
async Microsoft.Azure.WebJobs.Host.Executors.FunctionExecutor.ExecuteWithLoggingAsync(IFunctionInstanceEx instance,FunctionStartedMessage message,FunctionInstanceLogEntry instanceLogEntry,ParameterHelper parameterHelper,ILogger logger,CancellationToken cancellationToken) 
D:\a\_work\1\s\src\Microsoft.Azure.WebJobs.Host\Executors\FunctionExecutor.cs 
 /352    
System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()    
async Microsoft.Azure.WebJobs.Host.Executors.FunctionExecutor.TryExecuteAsync(IFunctionInstance functionInstance,CancellationToken cancellationToken) 
D:\a\_work\1\s\src\Microsoft.Azure.WebJobs.Host\Executors\FunctionExecutor.cs 
 /108
Azure Functions
Azure Functions
An Azure service that provides an event-driven serverless compute platform.
5,909 questions
Azure
Azure
A cloud computing platform and infrastructure for building, deploying and managing applications and services through a worldwide network of Microsoft-managed datacenters.
1,409 questions
{count} votes

1 answer

Sort by: Most helpful
  1. MuthuKumaranMurugaachari-MSFT 22,441 Reputation points Moderator
    2023-10-06T14:48:15.52+00:00

    SangeethaP Thanks for posting your question in Microsoft Q&A. You can use all the packages available in the public repo https://pypi.org/project/ or install local packages as described in the developer guide. However, important to note that some packages are only supported in Windows, but Python is supported only on a Linux based hosting plan, and hence you might face ModuleNotFoundError and ImportError.

    From the exception above, it appears that when loading package pythonnet it failed with Could not find libmono error (from pytabular package) and there is a discussion: import clr not working with mono on linux regarding the same. I think this specific issue is more related to pythonnet library with runtime Linux or pytabular (didn't describe Windows/Linux) and please reach out to the GitHub repo or discussion page to help with that.

    I hope this helps and let me know if any other questions.


    If you found the answer to your question helpful, please take a moment to mark it as "Yes" for others to benefit from your experience. Or simply add a comment tagging me and would be happy to answer your questions.

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.