I have created an image processing script in Python
(with dlib
and OpenCV
) - I was wondering how I can bring this functionality to Azure Functions, so that the script can be called via an API. As Python
is still in preview for Azure Functions
I wanted to know if anybody here has experience with bringing modules to Azure Functions
and if it's possible to install OpenCV
there?
相关问题
- how to define constructor for Python's new Nam
- streaming md5sum of contents of a large remote tar
- How to get the background from multiple images by
- running headless chrome in an microsoft azure web
- Evil ctypes hack in python
so I figured a dirty hack, it will install the package on the first run and throw an error, so the function will restart. Follow these steps:
Do something like (there probably is a better way, but I'm really new to python):
So the reason behind --user is that it won't let me install it with admin privileges... Also if you do include the requirements.txt with your git repository the packages are installed to the WebApp, but it appears that the Function got its own python environment, so you have to install packages manually.
So the only real trick it to find the appropriate wheel package (I strongly believe that Function is using Python 2.7, I couldn't get it to work with packages for Python 3.4)
You can bring your own modules to your Function by uploading them into the a
lib
folder residing in the same folder as your Function.However, in the context of OpenCV, it is not a supported scenario at the moment. The default Python version being used in the Azure Function environment is Python 2.7. If you try to execute a Function code using OpenCV for Python 2.7, the error message you will get would be similar to the following,
The fix for this is to update the
numpy
version used byPython 2.7
, but you will not be able to run the update yourself.As you have noted, Python language support for Azure Functions is in an experimental stage right now. These issues will be addressed when Python is fully on-boarded as a first-class language.