When I attempt to deploy my application to Heroku I receive the following error:
File "/app/project/app/_ _init__.py", line 22, in <module> File "/app/project/app/views.py", line 6, in <module> import cv2 from .cv2 import * File "/app/.heroku/python/lib/python3.6/site-packages/cv2/_ _init__.py", line 4, in <module> 2018-03-24T20:40:55.986945+00:00 app[web.1]: ImportError: libSM.so.6: cannot open shared object file: No such file or directory```
OpenCV is unable to find the libsm directory, however this application runs correctly locally. I have tried using a specific buildpack however those did not seem to find my site-packages
folder.
How do I use openCV (python) on Heroku?
You have to install some dependencies, as Heroku will not automatically do it for you.
libsm6
libxrender1
libfontconfig1
libice6
NOTE: Aptfile should not have any .txt or any other extension. Just like the Procfile
Push the edited code to Github
In heroku dashboard,
goto your-app --> settings --> buildpacks --> add buildpacks --> https://github.com/heroku/heroku-buildpack-apt.git
copy and paste this link --> add buildpack
Deploy your app
New Aptfile and requirements.txt attributes works for me:
libsm6
libxrender1
libfontconfig1
libice6
opencv-python-headless==4.2.0.32
Remember to have the Buildpack included in settings.
https://github.com/heroku/heroku-buildpack-apt
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With