Trying to configure Nginx gunicornb Flask, gunicornb when you start invisible Flask. Why?

Got a question , learn to configure nginx. Now set the flask.
While the structure of the site such

name_site
-app
--app.py
--static
---logo.png

-env

set virtuallenv,
launched mounted Flask
here is the result:

$ sudo pip freeze
click==6.7
Flask==0.12.2
itsdangerous==0.24
Jinja2==2.9.6
MarkupSafe==1.0
pycurl==7.43.0
pygobject==3.20.0
python-apt==1.1.0b1
unattended-upgrades==0.1
virtualenv==15.1.0
Werkzeug==0.12.2
The directory '/home/iz/.cache/pip/http' or its parent directory is not owned by the current user and the cache has been disabled. Please check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's-H flag.


then I went out virtuallenv command deactivate

then set up nginx configs well written app.py:

from flask import Flask, jsonify
app = Flask(__name__)

@app.route('/')
def index():
 return 'Flask is running!'

@app.route('/data')
def names():
 data = {"names": ["John", "Jacob", "Julie", "Jennifer"]}
 return jsonify(data)

if __name__ == '__main__':
 app.run()


then I go into the folder
name_site/app/
and run the command gunicorn app:app-b localhost:8000
and it gives me:

Traceback (most recent call last):
 File "/usr/lib/python2.7/dist-packages/gunicorn/arbiter.py", line 515, in spawn_worker
worker.init_process()
 File "/usr/lib/python2.7/dist-packages/gunicorn/workers/base.py", line 122, in init_process
self.load_wsgi()
 File "/usr/lib/python2.7/dist-packages/gunicorn/workers/base.py", line 130, in load_wsgi
 self.wsgi = self.app.wsgi()
 File "/usr/lib/python2.7/dist-packages/gunicorn/app/base.py", line 67, in wsgi
 self.callable = self.load()
 File "/usr/lib/python2.7/dist-packages/gunicorn/app/wsgiapp.py", line 65, in load
 return self.load_wsgiapp()
 File "/usr/lib/python2.7/dist-packages/gunicorn/app/wsgiapp.py", line 52, in load_wsgiapp
 return util.import_app(self.app_uri)
 File "/usr/lib/python2.7/dist-packages/gunicorn/util.py", line 366, in import_app
__import__(module)
 File "/var/www/itant/app/app.py", line 1, in <module>
 from flask import Flask, jsonify
ImportError: No module named flask
[2017-10-09 17:17:14 +0000] [22142] [INFO] Worker exiting (pid: 22142)
[2017-10-09 17:17:14 +0000] [22137] [INFO] Shutting down: Master
[2017-10-09 17:17:14 +0000] [22137] [INFO] Reason: Worker failed to boot.</module>


And the question is why?
I'm right nakosyachil again or am I missing something, or not run?
June 14th 19 at 18:16
1 answer
June 14th 19 at 18:18
Solution
Packages installed inside the virtualenv, available only when you activate the virtualenv. Beyond them, by default, no. Run outside the virtualenv interpreter seeks in the global system packages directory in the virtualenv.

you need to install gunicorn using pip inside a virtualenv and call it from a virtualenv/bin/
docs.gunicorn.org/en/stable/deploy.html#using-virt...

Find more questions by tags FlaskNginxPython