Skip to content Skip to sidebar Skip to footer

How To Use Opencv With Heroku

When I attempt to deploy my application to Heroku I receive the following error: File '/app/project/app/_ _init__.py', line 22, in File '/app/project/app/views.py',

Solution 1:

You can install these missing libraries taking advantage of the heroku-buildpack-apt.

At the time of this writing, I have succesfully done it for this repo, hosted here, with the following steps:

  1. Add heroku-buildpack-apt to your buildpacks on Heroku platform
  2. Create a file named Aptfile and add the following libs:
libsm6
libxrender1
libfontconfig1
libice6

(one per line). Example here.

Edit: in newer versions of OpenCV, you need only to list python-opencv on the Aptfile, as seen in the docs.

Solution 2:

Use opencv-python-headless as it is out of libSM6 dependency. check this out. Add the following line your requirements.txt and remove the old open-cv entry:

opencv-python-headless==4.2.0.32

Solution 3:

New Aptfile and requirements.txt attributes works for me:

in Aptfile

libsm6
libxrender1
libfontconfig1
libice6

in requirements.txt

opencv-python-headless==4.2.0.32

Remember to have the Buildpack included in settings.

https://github.com/heroku/heroku-buildpack-apt

Solution 4:

For windows users, be sure to use unix style line endings in the Aptfile when following @Lelo suggestion above

Solution 5:

Referring to Lelo's answer regarding the installation of libraries, OpenCV has changed their required libraries (4.4.0 at the time of writing).

Hence, to get the latest ones, you just need python-opencv in the Aptfile instead of the other libraries.

This was referred to Install OpenCV-Python in Ubuntu.

Post a Comment for "How To Use Opencv With Heroku"