I have Ubuntu+NGINX+Gunicorn with a virtual environment that works with Python 3 setup but my Flask app still runs as 2.7.6. I have methodically followed the instructions but I cannot find a resolution.
Gunicorn config file
[program:app-server]
command = gunicorn app:app -b localhost:8000
directory = /home/www/app-server
user = appuser
Project directory structure
app-server
----app.py
----venv (virtual environment)
Gunicorn is itself a Python application; the Gunicorn PPA only publishes Python 2 versions.
You'd install Gunicorn into Python 3 instead (using pip
, preferably into your virtualenv) and run that version:
/home/www/app-server/venv/bin/gunicorn
Although the question is more than a year old, but i figured i should add my answer in case any one come searching
open this file "/usr/bin/gunicorn" with a text editor. In my case I used vim with sudo in other to be able to edit the file
then change the python version to python3 usr/bin/python2.7 will be usr/bin/python3
then change the version number in the file to the version number of the gunicorn installed in virtual env. directory if both are not the same. In my case the version number in the file was 17.0 but what i have is 19.6.0
Note that there are two places to change the version number in the file.
#! /usr/bin/python3
# EASY-INSTALL-ENTRY SCRIPT'gunicorn==17.5','console_scripts','gunicorn'
__requires__ = 'gunicorn==19.6.0'
import sys
from pkg_resources import load_entry_point
if __name__ == '__main__':
sys.exit(
load_entry_point('gunicorn==19.6.0', console_scripts,
'gunicorn')
)
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