Whenever I'm creating a function app locally (with vscode) the project gets created,
When I debug locally the az
function, the debugger runs successfully,
When I add any library in the requirements.txt
file, and try to debug, the library gets installed, but I'm getting a huge error as the following:
Does it make sense? Is there any explanation that explains why I'm at the virtual env
of the az
function, and I'm getting this error? I'm seeing the libraries at the debugger level with:
import sysimport osdef get_virtual_env_path():if hasattr(sys, 'real_prefix') or (hasattr(sys, 'base_prefix') and sys.base_prefix != sys.prefix):\# Virtual environment is likely activereturn sys.prefixelif 'VIRTUAL_ENV' in os.environ:\# Check if VIRTUAL_ENV environment variable is setreturn os.environ\['VIRTUAL_ENV'\]else:return None# Example usagevirtual_env_path = get_virtual_env_path()if virtual_env_path:print(f"The path to the active virtual environment is: {virtual_env_path}")else:print("No virtual environment is currently active.")
It's the case for all my az functions ones were correctly behaving,
Worker failed to load function: 'HttpTrigger1' with functionId: '62b41d74-8a9b-46b9-a6db-9ccabee3c906'. [2024-02-01T16:26:42.644Z] Result: Failure Exception: ModuleNotFoundError: No module named 'pandas'. Please check the requirements.txt file for the missing module. For more info, please refer the troubleshooting guide: https://aka.ms/functions-modulenotfound Stack: File "C:\Program Files\Microsoft\Azure Functions Core Tools\workers\python\3.9/WINDOWS/X64\azure_functions_worker\dispatcher.py", line 387, in _handle__function_load_request func = loader.load_function( File "C:\Program Files\Microsoft\Azure Functions Core Tools\workers\python\3.9/WINDOWS/X64\azure_functions_worker\utils\wrappers.py", line 48, in call raise extend_exception_message(e, message) File "C:\Program Files\Microsoft\Azure Functions Core Tools\workers\python\3.9/WINDOWS/X64\azure_functions_worker\utils\wrappers.py", line 44, in call return func(*args, **kwargs) File "C:\Program Files\Microsoft\Azure Functions Core Tools\workers\python\3.9/WINDOWS/X64\azure_functions_worker\loader.py", line 194, in load_function mod = importlib.import_module(fullmodname) File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.9_3.9.3568.0_x64__qbz5n2kfra8p0\lib\importlib\__init__.py", line 127, in import_module return _bootstrap._gcd_import(name[level:], package, level) File "C:\Users\User\Documents\Projects\project_test\test\HttpTrigger1\__init__.py", line 4, in <module> import pandas as pd
.
Edit Solution : I have found the root cause,
After days of investigations i figured out that when i launch a function in the debugger (any func host start) related process, azurefunction launches some biuil-in enviromenet dependencies + my .env file so the problem was that there were a dependency conflict on the azure func start,
- I deleted the cache for vscode, Removed vscode
- Important : Deleted cache + fully delete azure function core tools as well as all the related vscode extension, which don't gets deleted during uninstall
- Deleted python
- Cleaned my laptop for empty / corrupted folders
- Re-install all
And we are good.
Thanks everyone for your answer, much apperciated.