ModuleNotFoundError: No module named 'azureml'.
Is your question related to a specific version? If so, please specify:
What binding does your question apply to, if any? (e.g. Blob Trigger, Event Hub Binding, etc)
Question
Hi
i am trying to create an azure function to call a machine learning model (pkl file) stored in azure blob. the requirements.txt looks like this
# DO NOT include azure-functions-worker in this file # The Python Worker is managed by Azure Functions platform # Manually managing azure-functions-worker may cause unexpected issues
azure-functions ipython optuna openpyxl hyperopt seaborn pandas numpy lime sklearn shap==0.34.0 xgboost azureml-core
Following is my init.py file import logging
import azure.functions as func from azureml.core import Workspace, Experiment, Run, Datastore,Dataset
def main(req: func.HttpRequest) -> func.HttpResponse: logging.info('Python HTTP trigger function processed a request.')
name = req.params.get('name')
if not name:
try:
req_body = req.get_json()
except ValueError:
pass
else:
name = req_body.get('name')
if name:
return func.HttpResponse(f"Hello, {name}. This HTTP triggered function executed successfully.")
else:
return func.HttpResponse(
"This HTTP triggered function executed successfully. Pass a name in the query string or in the request body for a personalized response.",
status_code=200
)
when i call func start local in powershell in admin mode i get the following error
Worker failed to function id 0bec684c-4614-4c79-a191-97cbb9c940dc.
[2021-02-10T17:50:23.445Z] Result: Failure
Exception: ModuleNotFoundError: No module named 'azureml'. Troubleshooting Guide: https://aka.ms/functions-modulenotfound
Stack: File "C:\ProgramData\chocolatey\lib\azure-functions-core-tools-3\tools\workers\python\3.8\WINDOWS\X64\azure_functions_worker\dispatcher.py", line 271, in handle__function_load_request
func = loader.load_function(
File "C:\ProgramData\chocolatey\lib\azure-functions-core-tools-3\tools\workers\python\3.8\WINDOWS\X64\azure_functions_worker\utils\wrappers.py", line 34, in call
raise extend_exception_message(e, message)
File "C:\ProgramData\chocolatey\lib\azure-functions-core-tools-3\tools\workers\python\3.8\WINDOWS\X64\azure_functions_worker\utils\wrappers.py", line 32, in call
return func(*args, **kwargs)
File "C:\ProgramData\chocolatey\lib\azure-functions-core-tools-3\tools\workers\python\3.8\WINDOWS\X64\azure_functions_worker\loader.py", line 76, in load_function
mod = importlib.import_module(fullmodname)
File "C:\ProgramData\Anaconda3\lib\importlib_init.py", line 127, in import_module
return _bootstrap.gcd_import(name[level:], package, level)
File "D:\datascience\hrproject\predictempatt_init.py", line 4, in
could you please let me know why i am getting the module not found error.
Thanks
Can you please confirm if the virtual environment contains the modules and if it is activated, when you are running func host start?
Thanks vrdmr. following is the list of commands executed in sequence:
- conda create --name myenv
- conda activate
- pip install -r requirements.txt
- func start local
using "pip list" shows list of all the modules installed. Now i am getting Worker failed to function id 4a84bf17-3762-4cbe-b690-539e4ce14b34. [2021-02-11T08:35:01.727Z] Result: Failure Exception: ModuleNotFoundError: No module named 'ruamel'. Troubleshooting Guide: https://aka.ms/functions-modulenotfound
azure cli tools: version 3.0.3284
I was having that issue until I realized that I have many versions of python loaded If you follow those steps above you will see when the function starts it's invoking a different version of python than the one that you have on the pip install above.
under settings.json check the setting "python.pythonPath"
and compare it with the one when you open the regular terminal.
hope this helps
Hi @praymalik2000 , Can we know if this is still persisting, we apologize for not following up frequently.