Gunicorn not running under supervisor

I'm running a flask app using Gunicorn. Running from the command line works just fine. When I try to run it using supervisorctl, I get an error:

File "/home/flask_app/app.py", line 3, in <module>
import numpy as np
ModuleNotFoundError: No module named 'numpy'</module>

If I comment out numpy, the same error occurs with sklearn. How do I get supervisor to use the same environment that running manually from the shell uses. I haven't used any type of virtual environments when installing the python modules required to run my app.
Thank…

1 Reply

I'm not familiar with Flask, though I am somewhat familiar with Python errors like this.

In Python, there are Absolute and Relative imports, and this error might be caused by this: Absolute vs Relative Imports in Python

A fix for this can be found here:
Relative imports - ModuleNotFoundError: No module named x

It may also be related to how these are handled in Flask, specifically where the modules reside and where the app is looking for them.

Reply

Please enter an answer
Tips:

You can mention users to notify them: @username

You can use Markdown to format your question. For more examples see the Markdown Cheatsheet.

> I’m a blockquote.

I’m a blockquote.

[I'm a link] (https://www.google.com)

I'm a link

**I am bold** I am bold

*I am italicized* I am italicized

Community Code of Conduct