Reputation: 21
I am trying to export my computer vision API, which is functioning correctly under macOS, to an Azure Function.
I tried to use the docker approach:
func azure functionapp publish --build-native-deps
but I keep getting the error:
can't import cv2 and imutils
and
Exception: ImportError: libgthread-2.0.so.0: cannot open shared object file: No such file or directory
Here is the requirements.txt:
How do I solve this problem? Or must I switch to AWS Lambda?
I have access to Kudu if that's helpful.
Thanks in advance!
Upvotes: 0
Views: 1636
Reputation: 11
The Azure team has updated the default function image to include libglib2.0-dev
You will need to install the headless version of OpenCV through pip instead of the default.
https://pypi.org/project/opencv-python-headless/
Upvotes: 1
Reputation: 24138
I think the issue is lack of the necessary library libgthread
. To fix it, you need to add it into your Docker file to build your own image for your function deployment.
On Azure, please follow the section Build the image from the Docker file
of the offical document Create a function on Linux using a custom image
to add the code below in azure-functions/python:2.0
Docker file.
RUN apt-get update && \
apt-get install -y libglib2.0-dev
But it will add a new docker image layer, so you can add libglib2.0-dev
into azure-functions/base:2.0
like below.
# Line 19
RUN apt-get update && \
apt-get install -y gnupg wget unzip libglib2.0-dev && \
wget https://functionscdn.azureedge.net/public/ExtensionBundles/Microsoft.Azure.Functions.ExtensionBundle/1.0.0/Microsoft.Azure.Functions.ExtensionBundle.1.0.0.zip && \
mkdir -p /FuncExtensionBundles/Microsoft.Azure.Functions.ExtensionBundle/1.0.0 && \
unzip /Microsoft.Azure.Functions.ExtensionBundle.1.0.0.zip -d /FuncExtensionBundles/Microsoft.Azure.Functions.ExtensionBundle/1.0.0 && \
rm -f /Microsoft.Azure.Functions.ExtensionBundle.1.0.0.zip
Upvotes: 0