Unexpected ModuleNotFound errors setting up Azure Functions locally on Windows

Sammy Paykel 0 Reputation points
2024-08-14T10:06:08.77+00:00

Hi everyone, I'm copying my post over from Stack Overflow to see if anyone has some ideas here. This is my first time using Azure functions so I apologize if this is a noob question. My organization already set up everything for Azure in our repository, but now I'm attempting to run the functions locally on my Windows machine, which gives me a ton of ModuleNotFoundErrors. Here are the steps I'm taking to start the localhost:


> python -m venv .venv

> .venv\Scripts\activate

> pip install -r requirements.txt

> func start --python

I'm running my terminal as an administrator, and when I run pip install -r requirements.txt it says that all requirements are already satisfied. However, when I func start it returns a spew of ModuleNotFoundErrors, such as:


[2024-08-02T10:13:40.452Z] Result: Failure

Exception: ModuleNotFoundError: No module named 'azure.durable_functions'. Cannot find module. Please check the requirements.txt file for the missing module. For more info, please refer the troubleshooting guide: https://aka.ms/functions-modulenotfound. Current sys.path: ['C:\\ProgramData\\chocolatey\\lib\\azure-functions-core-tools\\tools\\workers\\python\\3.10\\WINDOWS\\X64', 'C:\\ProgramData\\chocolatey\\lib\\azure-functions-core-tools\\tools\\workers\\python\\3.10\\WINDOWS\\X64', 'C:\\Program Files\\WindowsApps\\PythonSoftwareFoundation.Python.3.10_3.10.3056.0_x64__qbz5n2kfra8p0\\python310.zip', 'C:\\Program Files\\WindowsApps\\PythonSoftwareFoundation.Python.3.10_3.10.3056.0_x64__qbz5n2kfra8p0\\DLLs', 'C:\\Program Files\\WindowsApps\\PythonSoftwareFoundation.Python.3.10_3.10.3056.0_x64__qbz5n2kfra8p0\\lib', 'C:\\Users\\spayk\\AppData\\Local\\Microsoft\\WindowsApps\\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0', 'C:\\Users\\spayk\\AppData\\Local\\Packages\\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\\LocalCache\\local-packages\\Python310\\site-packages', 'C:\\Program Files\\WindowsApps\\PythonSoftwareFoundation.Python.3.10_3.10.3056.0_x64__qbz5n2kfra8p0', 'C:\\Program Files\\WindowsApps\\PythonSoftwareFoundation.Python.3.10_3.10.3056.0_x64__qbz5n2kfra8p0\\lib\\site-packages', 'C:\\Users\\spayk\\project']

(This is just one example of a ModuleNotFound error out of many, the terminal gives me so many errors that it actually takes up the whole history of the shell, even if I scroll all the way back up to the top.)

This doesn't make sense to me since when I ran the pip install previously it returned Requirement already satisfied: azure-functions-durable==1.2.9 in c:\users\spayk\project\.venv\lib\site-packages (from -r requirements.txt (line 5)) (1.2.9). Additionally, when I look inside my .venv\Lib folder I can see the site packages installed there.

I've tried multiple ideas for fixing this issue, including even running an Ubuntu WSL so I can use tools like Homebrew and source commands. I think the problem might be with the paths leading towards the installs, but I'm not really sure how I could redirect those. For reference, everyone else in my organization develops on Mac, I'm the only Windows developer, so modifying the code base in a way that would mess up the Azure functionality on a MacOS environment isn't an option for me.

If anyone else has experienced something similar please let me know, and thanks in advance!

Azure Functions
Azure Functions
An Azure service that provides an event-driven serverless compute platform.
5,001 questions
Windows 11
Windows 11
A Microsoft operating system designed for productivity, creativity, and ease of use.
9,662 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Lily Ma 0 Reputation points Microsoft Employee
    2024-09-26T20:21:11.2366667+00:00

    Hi @Sammy Paykel , sorry you're running into this problem. What do you have in the requirements.txt?

    I ran into this error myself but was able to get the quickstart working by doing something similar to what you posted. Sharing just in case:

    1. In the requirements.txt, I have
         azure-functions
         azure-functions-durable
         
      
    2. In the root directory, create and activate a virtual env
         python3 -m venv path/to/venv    
         source path/to/venv/bin/activate
      
    3. Run pip3 install -r requirements.txt
    4. Run func host start

    I've also gotten the sample working by simply going to Run > Start Debugging on VSCode. When I do this, all the steps above are done for me automatically, because of how my VSCode is set up for debugging. You could give that a try too.

    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.