Question

How to install opencv with serverless function [python]?

Adding a python dependency to a DigitalOcean function seems straight-forward: https://www.digitalocean.com/community/questions/how-to-install-python-requirements-with-serverless-function

It appears to work when I install numpy and Pillow:
requirements.txt

numpy==1.24.1
Pillow==9.4.0

However, I’m having trouble when trying to add opencv:

opencv-python==4.7.0.68

When attempting to deploy from the CLI I get this error:

Error: While deploying action ‘test/crop’ (running remote build): The action exhausted its memory and was aborted.

Any tips?


Submit an answer


This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

Sign In or Sign Up to Answer

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Bobby Iliev
Site Moderator
Site Moderator badge
January 20, 2023

Hi there,

Your function seems to be running out of memory according to this part of the output that you’ve shared:

The action exhausted its memory and was aborted.

I’ve just answered a similar question on how to increase your function memory limit, I would recommend following the steps here:

https://www.digitalocean.com/community/questions/problem-in-working-with-xml-parsing-by-python

Let me know if you have any questions!

Best,

Bobby

Try DigitalOcean for free

Click below to sign up and get $200 of credit to try our products over 60 days!

Sign up