Local Azure Function: Customer packages not in sys path. This should never happen

5.9k views Asked by At

I'm encountering a weird warning with azure functions locally. Whenever I func start my function, I get these error messages:

Found Python version 3.10.12 (python3).

Azure Functions Core Tools
Core Tools Version:       4.0.5455 Commit hash: N/A  (64-bit)
Function Runtime Version: 4.27.5.21554

[2023-11-14T10:02:39.795Z] Customer packages not in sys path. This should never happen!
[2023-11-14T10:02:42.194Z] Worker process started and initialized.

In the host.json, extensionBundle version is [3.*, 4.0.0) In the local.settings.json, "FUNCTIONS_WORKER_RUNTIME": "python" The function app is based on the new model of python azure function (func init MyProjFolder --worker-runtime python --model V2 https://learn.microsoft.com/en-us/azure/azure-functions/functions-run-local?tabs=linux%2Cisolated-process%2Cnode-v4%2Cpython-v2%2Chttp-trigger%2Ccontainer-apps&pivots=programming-language-python)

My first interrogation is the first warning:

Customer packages not in sys path. This should never happen!. I'm using a virtual environment.

The function is starting correctly, but what is this warning?

local.settings.json:

{
    "IsEncrypted": false,
    "Values": {
      "FUNCTIONS_WORKER_RUNTIME": "python",
      "AzureWebJobsStorage": "UseDevelopmentStorage=true",
      "AzureWebJobsFeatureFlags": "EnableWorkerIndexing"
    }
  }
2

There are 2 answers

0
Pravallika KV On BEST ANSWER

This seems to be the issue with the latest version of Azure function Core tools (4.0.5455), which is published recently (6 days ago) as mentioned in the official doc.

enter image description here

I have created a python Azure function to check the same:

Python Version: 3.11.5

Azure Functions Core Tools
Core Tools Version:       4.0.5348 Commit hash: N/A  (64-bit)
Function Runtime Version: 4.24.5.21262
  • Didn't get any such warning:

enter image description here

  • Updated the Azure function Core tools version to 4.0.5455.

  • Running the same Azure Function again with below versions:

Python version 3.11.6 (py).

Azure Functions Core Tools
Core Tools Version:       4.0.5455 Commit hash: N/A  (64-bit)
Function Runtime Version: 4.27.5.21554

enter image description here

0
user459872 On

This warning will usually appear when you develop and run azure function locally. If you look at the source code of Python worker for Azure Functions this logging is happening here.

if CUSTOMER_PACKAGES_PATH not in sys.path:
    logger.warning("Customer packages not in sys path.")

CUSTOMER_PACKAGES_PATH is defined as:

CUSTOMER_PACKAGES_PATH = "/home/site/wwwroot/.python_packages/lib/site-packages"

As you can see the path starts with /home/site/wwwroot which is how the file path looks like post deployment. So, this check is meant to ensure that the paths are configured correctly after the deployment. You can ignore the warning when developing locally.