Since it is a personal memorandum, the description is rough. I'm sorry.
HEROKU recognizes that it is a Python program by the requirements.txt file. Therefore, create requirements.txt and save it in the directory where the Python program is located. It is easy to use pip freez to create requirements.txt. Type the following command.
Terminal
pip freeze > requirements.txt
This will create a file in your current directory that describes the libraries installed in your environment. If you have activated the virtual environment with venv, only the libraries installed in the virtual environment will be written out, so it is better to do it in the venv environment for version control.
You also need to create a Procfile to recognize the Python file that HEROKU launches. This has no extension, so you need to be careful when creating it with a text editor. The contents are as follows.
Procfile
web:gunicorn python filename:app
Since we are using gunicorn for WSGI, before creating requirements.txt
Terminal
pip install guincorn
Install gunicorn with.
When I deployed a program that imports openCV,
Terminal
ImportError: libSM.so.6: cannot open shared object file: No such file or directory
I got the error. It seems to be an error because libSM.so.6 is not in HEROKU. Therefore, enter the following command in the terminal to add buildpack.
Terminal
$ heroku buildpacks:add --index 1 https://github.com/heroku/heroku-buildpack-apt
Create an Aptfile with a text editor and save it in the same directory as requirements.txt. Please note that there is no extension.
Aptfile
libsm6
libxrender1
libfontconfig1
libice6
Now that the preparation is complete, deploy it.
Terminal
$ git add .
$ git commit -m "add_Aptfile"
$ git push heroku master
Now you can safely use openCV on HEROKU.
Recommended Posts