LauriLehman-8626 avatar image
0 Votes"
LauriLehman-8626 asked ·

Azure Python Function fails to load numpy after virtual environment was updated to Ubuntu 20.04

Yesterday I started to have a strange error in an Azure Python Function:

 Result: Failure
 Exception: ImportError: 
 Importing the numpy C-extensions failed. This error can happen for
 many reasons, often due to issues with your setup or how NumPy was
 We have compiled some common reasons and troubleshooting tips at:

 Please note and check the following:
   * The Python version is: Python3.6 from "/usr/local/bin/python"
   * The NumPy version is: "1.19.5"
 and make sure that they are the versions you expect.
 Please carefully study the documentation linked above for further help.
 Original error was: No module named 'numpy.core._multiarray_umath'
 . Troubleshooting Guide:
 Stack:   File "/azure-functions-host/workers/python/3.6/LINUX/X64/azure_functions_worker/", line 275, in _handle__function_load_request
   File "/azure-functions-host/workers/python/3.6/LINUX/X64/azure_functions_worker/utils/", line 34, in call
     raise extend_exception_message(e, message)
   File "/azure-functions-host/workers/python/3.6/LINUX/X64/azure_functions_worker/utils/", line 32, in call
     return func(*args, **kwargs)
   File "/azure-functions-host/workers/python/3.6/LINUX/X64/azure_functions_worker/", line 76, in load_function
     mod = importlib.import_module(fullmodname)
   File "/usr/local/lib/python3.6/importlib/", line 126, in import_module
     return _bootstrap._gcd_import(name[level:], package, level)
   File "<frozen importlib._bootstrap>", line 994, in _gcd_import
   File "<frozen importlib._bootstrap>", line 971, in _find_and_load
   File "<frozen importlib._bootstrap>", line 941, in _find_and_load_unlocked
   File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
   File "<frozen importlib._bootstrap>", line 994, in _gcd_import
   File "<frozen importlib._bootstrap>", line 971, in _find_and_load
   File "<frozen importlib._bootstrap>", line 955, in _find_and_load_unlocked
   File "<frozen importlib._bootstrap>", line 665, in _load_unlocked
   File "<frozen importlib._bootstrap_external>", line 678, in exec_module
   File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
   File "/home/site/wwwroot/MyFuncName/", line 5, in <module>
     from mycustommodule import mycustomsubmodule
   File "/home/site/wwwroot/mycustommodule/", line 6, in <module>
     from .anothersubmodule import module_xyz
   File "/home/site/wwwroot/mycustommodule/", line 7, in <module>
     from numpy import isnan
   File "/home/site/wwwroot/.python_packages/lib/site-packages/numpy/", line 140, in <module>
     from . import core
   File "/home/site/wwwroot/.python_packages/lib/site-packages/numpy/core/", line 48, in <module>
     raise ImportError(msg)

I am using Python 3.6 because on of my packages depends on it. Numpy version 1.19.5 is compatible with Python 3.6. This is my full requirements file:


This problem started to appear yesterday. From Azure DevOps deployment logs, I can see that the virtual environment OS changed from Ubuntu 18.04 to 20.04 and that's when the problems started.

I can file a bug request on this, but what is the correct repository? Azure Functions host runtime or Python worker runtime repository?

EDIT: Note that the error is caused by the module numpy.core._multiarray_umath. When I open the Function files in VS Code, I can see that .python_packages/lib/site-packages/numpy/core contains file, which seems to refer to the wrong Python version.

EDIT 2: Bug report filed: 1860

· 2
10 |1000 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

The Python Worker Runtime repository might be a better place since this is Python specific, but this doesn't seem to be related to Azure Functions but more towards Azure DevOps and change in the underlying OS used.

Could you confirm that the virtual env is still being created for python 3.6 correctly?

0 Votes 0 ·
LauriLehman-8626 avatar image LauriLehman-8626 PramodValavala-MSFT ·

Yes, it seems that this issue is related to the DevOps agent. I deployed the function manually from VS code and numpy is now working with Python 3.6.

I created the bug report in the Azure Functions, but I will remove it since it is not related directly to Functions. This might be more relevant issue:

0 Votes 0 ·

0 Answers