Gunicorn with Flask using wrong Python

前端 未结 4 626
[愿得一人]
[愿得一人] 2021-02-04 02:30

I\'m trying to bootstrap a Flask app on a Gunicorn server. By putting the two tools\' docs together, plus searching around on SO, this is what I have so far... but it\'s not qui

相关标签:
4条回答
  • 2021-02-04 02:34

    I have the same problem as You. The problem is that gunicorn for some reason load the enviroment outside your virtual env. I solved by uninstalling the package gunicorn outside virtual enviroment;

    (env) $ deactivate
    $ sudo pip uninstall gunicorn
    

    So you come back to your env and try to run. In my case env folder I typed:

    $ source env/bin/activate
    (env) $ pip install gunicorn
    (env) $ gunicorn server:app
    2013-10-19 20:40:56 [11923] [INFO] Starting gunicorn 18.0
    2013-10-19 20:40:56 [11923] [INFO] Listening at: http://127.0.0.1:8000 (11923)
    2013-10-19 20:40:56 [11923] [INFO] Using worker: sync
    2013-10-19 20:40:56 [11926] [INFO] Booting worker with pid: 11926
    
    0 讨论(0)
  • 2021-02-04 02:37

    I tried creating a new env. and freshly installed the dependency, it worked for me. Also, I am using miniconda to manage my env.

    0 讨论(0)
  • 2021-02-04 02:45

    Gunicorn may be installed at multiple location in your system. It may be present in

    1. OS default Python Path
    2. Anaconda Python Path

    By default when you specify

    gunicorn -w 4 -b 127.0.0.1:5000 flaskApp:app

    You are referrng to operating system's default Python where in the same path flask package is not installed results in error. Better specify which gunicorn you are reffering to by providing proper path to gunicorn

    /home/sunil/anaconda2/bin/gunicorn -w 4 -b 127.0.0.1:5000 flaskApp:app

    0 讨论(0)
  • 2021-02-04 02:46

    The gunicorn utility may be running out of the system path rather than your virtualenv.

    Make sure to pip install gunicorn into the virtualenv.

    Here's the pip freeze of a virtualenv I setup to run your app:

    (so_2)20:38:25 ~/code/tmp/flask_so$ pip freeze
    Flask==0.10.1
    Flask-SQLAlchemy==1.0
    Jinja2==2.7.1
    MarkupSafe==0.18
    SQLAlchemy==0.8.2
    Werkzeug==0.9.4
    gunicorn==18.0
    itsdangerous==0.23
    wsgiref==0.1.2
    

    In reality, I only ran these pip installs:

    $ pip install flask
    $ pip install gunicorn
    $ pip install Flask-SQLAlchemy
    
    0 讨论(0)
提交回复
热议问题