A memorandum of stumbling on my personal HEROKU & Python (Flask)

Since it is a personal memorandum, the description is rough. I'm sorry.

HEROKU doesn't recognize Python (requirements.txt)

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.

OpenCV related error (libSM.so.6)

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

A memorandum of stumbling on my personal HEROKU & Python (Flask)
A memorandum for touching python Flask on heroku
[Python] A memorandum of beautiful soup4
A memorandum of python string deletion process
A memorandum of calling Python from Common Lisp
A memorandum of extraction by python bs4 request
A story about running Python on PHP on Heroku
Python memorandum (personal bookmark)
A collection of code often used in personal Python
A memorandum of kernel compilation
A small memorandum of openpyxl
A record of hell lessons imposed on beginner Python students
(Failure) Deploy a web app made with Flask on heroku
Handling of python on mac
A memorandum about correlation [Python]
[GCP] A memorandum when running a Python program on Cloud Functions
[Introduction to AWS] A memorandum of building a web server on AWS
A memorandum about Python mock
A memorandum of using eigen3
[First personal development] The story of deploying the Flask app and Twitter's automatic reply bot on Heroku
A memorandum of understanding for the Python package management tool ez_setup
[Python] Visualize overseas Japanese soccer players on a map as of 2021.1.1
[Python] A workaround based on common errors and my past experience
Easy! Implement a Twitter bot that runs on Heroku in Python
I made a Nyanko tweet form with Python, Flask and Heroku
A memorandum of scraping & machine learning [development technique] by Python (Chapter 4)
A memorandum of scraping & machine learning [development technique] by Python (Chapter 5)
Memorandum of understanding when Python is run on EC2 with Apache
A memorandum regarding the acquisition of the Python3 engineer certification basic exam
I did a lot of research on how Python is executed
Get the number of readers of a treatise on Mendeley in Python
Building a Python environment on Mac
A good description of Python decorators
[Python] The stumbling block of import
Memorandum on Memoization of recursive series
Building a Python environment on Ubuntu
Create a Python environment on Mac (2017/4)
A brief summary of Python collections
Memorandum on Memoization of recursive functions
python + django + scikit-learn + mecab (1) on heroku
Next, use Python (Flask) for Heroku!
A memorandum of files under conf.d
python + django + scikit-learn + mecab (2) on heroku
Git & Github & python & VScode Personal memorandum
Deploy Flask app on heroku (bitterly)
Create a python environment on centos
Python json.loads () returns str on Heroku
Deploy the Flask app on Heroku
Environment construction of python3.8 on mac
Deploy the Flask app on heroku
Memorandum of beginners Python "isdigit" movement
Build a python3 environment on CentOS7
A memorandum of closure survey contents
Periodically run Python on Heroku Scheduler
Future population of my town on Plotly/Dash to find a place to live
A story about my new study of Python after 3 years of MATLAB experience
Run a batch of Python 2.7 with nohup on Amazon Linux AMI on EC2
A story about deploying a Twitter-linked app created using Flask + gunicorn on Heroku
A memorandum because I stumbled on trying to use MeCab in Python
Create a web application execution environment of Python3.4 + Nginx + uWSGI + Flask with haste using venv on Ubuntu 14.04 LTS
Build a python environment on MacOS (Catallina)